mcp-docs-service 0.2.17 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +38 -189
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.js +640 -591
  4. package/dist/index.js.map +1 -1
  5. package/package.json +32 -46
  6. package/CHANGELOG.md +0 -188
  7. package/cursor-wrapper.js +0 -199
  8. package/dist/cli/bin.d.ts +0 -8
  9. package/dist/cli/bin.js +0 -133
  10. package/dist/cli/bin.js.map +0 -1
  11. package/dist/handlers/docs.d.ts +0 -26
  12. package/dist/handlers/docs.js +0 -513
  13. package/dist/handlers/docs.js.map +0 -1
  14. package/dist/handlers/file.d.ts +0 -32
  15. package/dist/handlers/file.js +0 -222
  16. package/dist/handlers/file.js.map +0 -1
  17. package/dist/handlers/index.d.ts +0 -1
  18. package/dist/handlers/index.js +0 -3
  19. package/dist/handlers/index.js.map +0 -1
  20. package/dist/schemas/index.d.ts +0 -1
  21. package/dist/schemas/index.js +0 -3
  22. package/dist/schemas/index.js.map +0 -1
  23. package/dist/schemas/tools.d.ts +0 -164
  24. package/dist/schemas/tools.js +0 -53
  25. package/dist/schemas/tools.js.map +0 -1
  26. package/dist/types/docs.d.ts +0 -74
  27. package/dist/types/docs.js +0 -2
  28. package/dist/types/docs.js.map +0 -1
  29. package/dist/types/file.d.ts +0 -21
  30. package/dist/types/file.js +0 -2
  31. package/dist/types/file.js.map +0 -1
  32. package/dist/types/index.d.ts +0 -44
  33. package/dist/types/index.js +0 -4
  34. package/dist/types/index.js.map +0 -1
  35. package/dist/types/tools.d.ts +0 -11
  36. package/dist/types/tools.js +0 -2
  37. package/dist/types/tools.js.map +0 -1
  38. package/dist/utils/file.d.ts +0 -24
  39. package/dist/utils/file.js +0 -94
  40. package/dist/utils/file.js.map +0 -1
  41. package/dist/utils/index.d.ts +0 -1
  42. package/dist/utils/index.js +0 -3
  43. package/dist/utils/index.js.map +0 -1
  44. package/dist/utils/path.d.ts +0 -16
  45. package/dist/utils/path.js +0 -70
  46. package/dist/utils/path.js.map +0 -1
  47. package/mcp-inspector-wrapper.js +0 -208
  48. package/npx-standalone.cjs +0 -216
  49. package/npx-wrapper.js +0 -119
@@ -1,44 +0,0 @@
1
- export interface DocumentMetadata {
2
- title?: string;
3
- order?: number;
4
- description?: string;
5
- author?: string;
6
- date?: Date;
7
- tags?: string[];
8
- status?: string;
9
- [key: string]: any;
10
- }
11
- export interface DocumentEntry {
12
- path: string;
13
- name: string;
14
- metadata: DocumentMetadata;
15
- }
16
- export interface TreeEntry {
17
- name: string;
18
- path: string;
19
- type: string;
20
- metadata?: DocumentMetadata;
21
- children: TreeEntry[];
22
- error?: string;
23
- }
24
- export interface NavigationItem {
25
- title: string;
26
- path: string | null;
27
- order: number;
28
- }
29
- export interface NavigationSection {
30
- title: string;
31
- path: string | null;
32
- items: NavigationItem[];
33
- order: number;
34
- }
35
- export type ToolResponse = {
36
- content: Array<{
37
- type: string;
38
- text: string;
39
- }>;
40
- metadata?: Record<string, any>;
41
- isError?: boolean;
42
- };
43
- export * from "./docs.js";
44
- export * from "./tools.js";
@@ -1,4 +0,0 @@
1
- // Re-export all types from specialized modules
2
- export * from "./docs.js";
3
- export * from "./tools.js";
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAiDA,+CAA+C;AAC/C,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Standard response format for tools
3
- */
4
- export type ToolResponse = {
5
- content: Array<{
6
- type: string;
7
- text: string;
8
- }>;
9
- metadata?: Record<string, any>;
10
- isError?: boolean;
11
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=tools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":""}
@@ -1,24 +0,0 @@
1
- import { FileInfo } from "../types/file.js";
2
- /**
3
- * Gets file statistics and information
4
- */
5
- export declare function getFileStats(filePath: string): Promise<FileInfo>;
6
- /**
7
- * Searches for files matching a pattern
8
- */
9
- export declare function searchFiles(rootPath: string, pattern: string, excludePatterns?: string[]): Promise<string[]>;
10
- /**
11
- * Normalizes line endings to LF
12
- */
13
- export declare function normalizeLineEndings(text: string): string;
14
- /**
15
- * Creates a unified diff between two text contents
16
- */
17
- export declare function createUnifiedDiff(originalContent: string, newContent: string, filepath?: string): string;
18
- /**
19
- * Applies edits to a file
20
- */
21
- export declare function applyFileEdits(filePath: string, edits: Array<{
22
- oldText: string;
23
- newText: string;
24
- }>, dryRun?: boolean): Promise<string>;
@@ -1,94 +0,0 @@
1
- import fs from "fs/promises";
2
- import path from "path";
3
- import { createTwoFilesPatch } from "diff";
4
- import { minimatch } from "minimatch";
5
- /**
6
- * Gets file statistics and information
7
- */
8
- export async function getFileStats(filePath) {
9
- const stats = await fs.stat(filePath);
10
- // Convert file mode to permission string (e.g., "rwxr-xr-x")
11
- const mode = stats.mode;
12
- const permissions = [
13
- stats.mode & 0o400 ? "r" : "-",
14
- stats.mode & 0o200 ? "w" : "-",
15
- stats.mode & 0o100 ? "x" : "-",
16
- stats.mode & 0o040 ? "r" : "-",
17
- stats.mode & 0o020 ? "w" : "-",
18
- stats.mode & 0o010 ? "x" : "-",
19
- stats.mode & 0o004 ? "r" : "-",
20
- stats.mode & 0o002 ? "w" : "-",
21
- stats.mode & 0o001 ? "x" : "-",
22
- ].join("");
23
- return {
24
- size: stats.size,
25
- created: stats.birthtime,
26
- modified: stats.mtime,
27
- accessed: stats.atime,
28
- isDirectory: stats.isDirectory(),
29
- isFile: stats.isFile(),
30
- permissions,
31
- };
32
- }
33
- /**
34
- * Searches for files matching a pattern
35
- */
36
- export async function searchFiles(rootPath, pattern, excludePatterns = []) {
37
- const results = [];
38
- async function search(currentPath) {
39
- const entries = await fs.readdir(currentPath, { withFileTypes: true });
40
- for (const entry of entries) {
41
- const entryPath = path.join(currentPath, entry.name);
42
- const relativePath = path.relative(rootPath, entryPath);
43
- // Check if path should be excluded
44
- if (excludePatterns.some((excludePattern) => minimatch(relativePath, excludePattern))) {
45
- continue;
46
- }
47
- if (entry.isDirectory()) {
48
- await search(entryPath);
49
- }
50
- else if (minimatch(relativePath, pattern)) {
51
- results.push(entryPath);
52
- }
53
- }
54
- }
55
- await search(rootPath);
56
- return results;
57
- }
58
- /**
59
- * Normalizes line endings to LF
60
- */
61
- export function normalizeLineEndings(text) {
62
- return text.replace(/\r\n/g, "\n");
63
- }
64
- /**
65
- * Creates a unified diff between two text contents
66
- */
67
- export function createUnifiedDiff(originalContent, newContent, filepath = "file") {
68
- return createTwoFilesPatch(filepath, filepath, normalizeLineEndings(originalContent), normalizeLineEndings(newContent), "", "", { context: 3 });
69
- }
70
- /**
71
- * Applies edits to a file
72
- */
73
- export async function applyFileEdits(filePath, edits, dryRun = false) {
74
- let content = await fs.readFile(filePath, "utf-8");
75
- content = normalizeLineEndings(content);
76
- // Apply all edits
77
- for (const edit of edits) {
78
- const { oldText, newText } = edit;
79
- const normalizedOldText = normalizeLineEndings(oldText);
80
- if (!content.includes(normalizedOldText)) {
81
- throw new Error(`Edit failed: Could not find text to replace in ${filePath}`);
82
- }
83
- content = content.replace(normalizedOldText, normalizeLineEndings(newText));
84
- }
85
- // Create a diff to show changes
86
- const originalContent = await fs.readFile(filePath, "utf-8");
87
- const diff = createUnifiedDiff(originalContent, content, filePath);
88
- // Write the changes if not a dry run
89
- if (!dryRun) {
90
- await fs.writeFile(filePath, content);
91
- }
92
- return diff;
93
- }
94
- //# sourceMappingURL=file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAA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Z,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1 +0,0 @@
1
- export * from "./path.js";
@@ -1,3 +0,0 @@
1
- // Re-export all utility functions
2
- export * from "./path.js";
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,cAAc,WAAW,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Normalizes a path consistently
3
- */
4
- export declare function normalizePath(p: string): string;
5
- /**
6
- * Expands the home directory in a path (e.g., ~/docs -> /home/user/docs)
7
- */
8
- export declare function expandHome(p: string): string;
9
- /**
10
- * Validates that a path is within allowed directories
11
- * @param p The path to validate
12
- * @param allowedDirectories Array of allowed directory paths
13
- * @returns The normalized path if valid
14
- * @throws Error if path is not within allowed directories
15
- */
16
- export declare function validatePath(p: string, allowedDirectories: string[]): Promise<string>;
@@ -1,70 +0,0 @@
1
- import path from "path";
2
- import os from "os";
3
- import fs from "fs/promises";
4
- /**
5
- * Normalizes a path consistently
6
- */
7
- export function normalizePath(p) {
8
- return path.normalize(p);
9
- }
10
- /**
11
- * Expands the home directory in a path (e.g., ~/docs -> /home/user/docs)
12
- */
13
- export function expandHome(p) {
14
- if (!p)
15
- return p;
16
- if (p === "~" || p.startsWith("~/")) {
17
- return p.replace(/^~/, os.homedir());
18
- }
19
- return p;
20
- }
21
- /**
22
- * Validates that a path is within allowed directories
23
- * @param p The path to validate
24
- * @param allowedDirectories Array of allowed directory paths
25
- * @returns The normalized path if valid
26
- * @throws Error if path is not within allowed directories
27
- */
28
- export async function validatePath(p, allowedDirectories) {
29
- // Handle empty path by using the first allowed directory
30
- if (!p) {
31
- return allowedDirectories[0];
32
- }
33
- // Resolve the path
34
- const normalizedPath = normalizePath(path.resolve(expandHome(p)));
35
- // Check if the path is exactly an allowed directory
36
- if (allowedDirectories.some((dir) => dir === normalizedPath)) {
37
- return normalizedPath;
38
- }
39
- // Check if the path is within any of the allowed directories
40
- const isAllowed = allowedDirectories.some((dir) => {
41
- const relativePath = path.relative(dir, normalizedPath);
42
- return (relativePath !== "" &&
43
- !relativePath.startsWith("..") &&
44
- !path.isAbsolute(relativePath));
45
- });
46
- if (!isAllowed) {
47
- // Try to resolve the path relative to the allowed directories
48
- for (const dir of allowedDirectories) {
49
- const resolvedPath = path.resolve(dir, p);
50
- try {
51
- // Check if the path exists
52
- await fs.access(resolvedPath);
53
- // If it exists, check if it's within an allowed directory
54
- const relativePath = path.relative(dir, resolvedPath);
55
- if (relativePath !== "" &&
56
- !relativePath.startsWith("..") &&
57
- !path.isAbsolute(relativePath)) {
58
- return resolvedPath;
59
- }
60
- }
61
- catch (error) {
62
- // Path doesn't exist, continue to the next directory
63
- }
64
- }
65
- // If we get here, the path is not allowed
66
- throw new Error(`Access denied: ${p} is not within allowed directories. Allowed directories: ${allowedDirectories.join(", ")}`);
67
- }
68
- return normalizedPath;
69
- }
70
- //# sourceMappingURL=path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAS;IACrC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EA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AAY,CAAC,CAAC;gBACtD,IACE,YAAY,KAAK,EAAE;oBACnB,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC;oBAC9B,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAC9B,CAAC;oBACD,OAAO,YAAY,CAAC;gBACtB,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,qDAAqD;YACvD,CAAC;QACH,CAAC;QAED,0CAA0C;QAC1C,MAAM,IAAI,KAAK,CACb,kBAAkB,CAAC,4DAA4D,kBAAkB,CAAC,IAAI,CACpG,IAAI,CACL,EAAE,CACJ,CAAC;IACJ,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC"}
@@ -1,208 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * MCP Inspector Wrapper
5
- *
6
- * This script is a wrapper for the MCP Docs Service that handles the MCP Inspector's argument format.
7
- * It extracts the docs directory from the arguments and passes it to the MCP Docs Service.
8
- */
9
-
10
- import path from "path";
11
- import { spawn } from "child_process";
12
- import fs from "fs";
13
- import { fileURLToPath } from "url";
14
-
15
- // Wrap everything in a try/catch to catch any initialization errors
16
- try {
17
- // Get the current directory
18
- const __filename = fileURLToPath(import.meta.url);
19
- const __dirname = path.dirname(__filename);
20
-
21
- // Redirect logs to stderr instead of stdout to avoid interfering with JSON communication
22
- const log = (...args) => {
23
- console.error(...args);
24
- };
25
-
26
- // Create a log file for debugging
27
- const logFile = path.join(process.cwd(), "inspector-debug.log");
28
- fs.writeFileSync(
29
- logFile,
30
- `MCP Inspector Wrapper called at ${new Date().toISOString()}\n`
31
- );
32
-
33
- // Get all arguments
34
- const args = process.argv.slice(2);
35
- fs.appendFileSync(
36
- logFile,
37
- `MCP Inspector Wrapper - Arguments: ${JSON.stringify(args)}\n`
38
- );
39
- fs.appendFileSync(logFile, `Working directory: ${process.cwd()}\n`);
40
- fs.appendFileSync(logFile, `Script directory: ${__dirname}\n`);
41
- log("MCP Inspector Wrapper - Arguments:", args);
42
-
43
- // List files in the package directory to debug
44
- try {
45
- const files = fs.readdirSync(__dirname);
46
- fs.appendFileSync(
47
- logFile,
48
- `Files in package dir: ${JSON.stringify(files)}\n`
49
- );
50
-
51
- // Check if dist directory exists
52
- const distDir = path.join(__dirname, "dist");
53
- if (fs.existsSync(distDir)) {
54
- const distFiles = fs.readdirSync(distDir);
55
- fs.appendFileSync(
56
- logFile,
57
- `Files in dist dir: ${JSON.stringify(distFiles)}\n`
58
- );
59
-
60
- // Check if cli directory exists
61
- const cliDir = path.join(distDir, "cli");
62
- if (fs.existsSync(cliDir)) {
63
- const cliFiles = fs.readdirSync(cliDir);
64
- fs.appendFileSync(
65
- logFile,
66
- `Files in cli dir: ${JSON.stringify(cliFiles)}\n`
67
- );
68
- } else {
69
- fs.appendFileSync(logFile, `CLI directory not found: ${cliDir}\n`);
70
- }
71
- } else {
72
- fs.appendFileSync(logFile, `Dist directory not found: ${distDir}\n`);
73
- }
74
- } catch (err) {
75
- fs.appendFileSync(logFile, `Error listing files: ${err.message}\n`);
76
- }
77
-
78
- // Find the docs directory in the arguments
79
- let docsDir = path.join(process.cwd(), "docs");
80
- let foundDocsDir = false;
81
-
82
- // Look for a path ending with /docs
83
- for (const arg of args) {
84
- if (arg.endsWith("/docs") || arg.includes("/docs ")) {
85
- const potentialPath = arg.split(" ")[0];
86
- log("Found potential docs path:", potentialPath);
87
- fs.appendFileSync(
88
- logFile,
89
- `Found potential docs path: ${potentialPath}\n`
90
- );
91
-
92
- if (fs.existsSync(potentialPath)) {
93
- docsDir = potentialPath;
94
- foundDocsDir = true;
95
- log("Using docs directory:", docsDir);
96
- fs.appendFileSync(logFile, `Using docs directory: ${docsDir}\n`);
97
- break;
98
- }
99
- }
100
- }
101
-
102
- if (!foundDocsDir) {
103
- log("No docs directory found in arguments, using default:", docsDir);
104
- fs.appendFileSync(
105
- logFile,
106
- `No docs directory found in arguments, using default: ${docsDir}\n`
107
- );
108
-
109
- // Ensure the docs directory exists
110
- if (!fs.existsSync(docsDir)) {
111
- fs.appendFileSync(logFile, `Creating docs directory: ${docsDir}\n`);
112
- try {
113
- fs.mkdirSync(docsDir, { recursive: true });
114
- fs.appendFileSync(logFile, `Successfully created docs directory\n`);
115
- } catch (error) {
116
- fs.appendFileSync(logFile, `Error creating docs directory: ${error}\n`);
117
- log(`Error creating docs directory: ${error}`);
118
- process.exit(1);
119
- }
120
- }
121
- }
122
-
123
- // Find the bin.js file
124
- let binPath = path.join(__dirname, "dist", "cli", "bin.js");
125
-
126
- // Check if the bin.js file exists
127
- if (!fs.existsSync(binPath)) {
128
- fs.appendFileSync(
129
- logFile,
130
- `bin.js not found at ${binPath}, searching...\n`
131
- );
132
-
133
- // Try to find bin.js in node_modules
134
- const nodeModulesPath = path.join(
135
- process.cwd(),
136
- "node_modules",
137
- "mcp-docs-service"
138
- );
139
- if (fs.existsSync(nodeModulesPath)) {
140
- const potentialBinPath = path.join(
141
- nodeModulesPath,
142
- "dist",
143
- "cli",
144
- "bin.js"
145
- );
146
- if (fs.existsSync(potentialBinPath)) {
147
- binPath = potentialBinPath;
148
- fs.appendFileSync(
149
- logFile,
150
- `Found bin.js in node_modules: ${binPath}\n`
151
- );
152
- }
153
- }
154
- }
155
-
156
- log("Spawning MCP Docs Service:", binPath, "--docs-dir", docsDir);
157
- fs.appendFileSync(
158
- logFile,
159
- `Spawning MCP Docs Service: ${binPath} --docs-dir ${docsDir}\n`
160
- );
161
-
162
- // Check if the bin file exists before trying to run it
163
- if (!fs.existsSync(binPath)) {
164
- fs.appendFileSync(logFile, `ERROR: bin.js not found at ${binPath}\n`);
165
- log(`ERROR: Could not find the MCP Docs Service binary at ${binPath}`);
166
- process.exit(1);
167
- }
168
-
169
- // Set environment variable to indicate we're running under MCP Inspector
170
- const env = { ...process.env, MCP_INSPECTOR: "true" };
171
-
172
- // Spawn the process with stdio inheritance
173
- // This ensures that the JSON communication between the MCP Inspector and the service
174
- // is not interrupted by our logs
175
- const child = spawn("node", [binPath, "--docs-dir", docsDir], {
176
- stdio: "inherit",
177
- env,
178
- });
179
-
180
- // Forward exit code
181
- child.on("exit", (code) => {
182
- fs.appendFileSync(logFile, `Child process exited with code ${code}\n`);
183
- process.exit(code);
184
- });
185
-
186
- // Handle errors
187
- child.on("error", (err) => {
188
- fs.appendFileSync(
189
- logFile,
190
- `Error spawning child process: ${err.message}\n`
191
- );
192
- log(`Error spawning MCP Docs Service: ${err.message}`);
193
- process.exit(1);
194
- });
195
- } catch (error) {
196
- // Write to a fallback log file in case the main one couldn't be created
197
- try {
198
- fs.writeFileSync(
199
- path.join(process.cwd(), "inspector-error.log"),
200
- `Fatal error in mcp-inspector-wrapper.js: ${error.message}\n${error.stack}\n`
201
- );
202
- } catch (e) {
203
- // Last resort, just log to console
204
- console.error(`Fatal error in mcp-inspector-wrapper.js: ${error.message}`);
205
- console.error(error.stack);
206
- }
207
- process.exit(1);
208
- }