mcp-docs-service 0.2.17 → 0.3.0
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.
- package/README.md +33 -199
- package/dist/index.d.ts +6 -0
- package/dist/index.js +640 -591
- package/dist/index.js.map +1 -1
- package/package.json +32 -46
- package/CHANGELOG.md +0 -188
- package/cursor-wrapper.js +0 -199
- package/dist/cli/bin.d.ts +0 -8
- package/dist/cli/bin.js +0 -133
- package/dist/cli/bin.js.map +0 -1
- package/dist/handlers/docs.d.ts +0 -26
- package/dist/handlers/docs.js +0 -513
- package/dist/handlers/docs.js.map +0 -1
- package/dist/handlers/file.d.ts +0 -32
- package/dist/handlers/file.js +0 -222
- package/dist/handlers/file.js.map +0 -1
- package/dist/handlers/index.d.ts +0 -1
- package/dist/handlers/index.js +0 -3
- package/dist/handlers/index.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -1
- package/dist/schemas/index.js +0 -3
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/tools.d.ts +0 -164
- package/dist/schemas/tools.js +0 -53
- package/dist/schemas/tools.js.map +0 -1
- package/dist/types/docs.d.ts +0 -74
- package/dist/types/docs.js +0 -2
- package/dist/types/docs.js.map +0 -1
- package/dist/types/file.d.ts +0 -21
- package/dist/types/file.js +0 -2
- package/dist/types/file.js.map +0 -1
- package/dist/types/index.d.ts +0 -44
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/tools.d.ts +0 -11
- package/dist/types/tools.js +0 -2
- package/dist/types/tools.js.map +0 -1
- package/dist/utils/file.d.ts +0 -24
- package/dist/utils/file.js +0 -94
- package/dist/utils/file.js.map +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -3
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/path.d.ts +0 -16
- package/dist/utils/path.js +0 -70
- package/dist/utils/path.js.map +0 -1
- package/mcp-inspector-wrapper.js +0 -208
- package/npx-standalone.cjs +0 -216
- package/npx-wrapper.js +0 -119
package/npx-standalone.cjs
DELETED
@@ -1,216 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
/**
|
4
|
-
* NPX Standalone Wrapper for MCP Docs Service
|
5
|
-
*
|
6
|
-
* This script is a standalone CommonJS wrapper that can be used directly with npx.
|
7
|
-
* It uses child_process.spawn to run the actual service, avoiding ES module issues.
|
8
|
-
*/
|
9
|
-
|
10
|
-
const fs = require("fs");
|
11
|
-
const path = require("path");
|
12
|
-
const { spawn } = require("child_process");
|
13
|
-
|
14
|
-
// Wrap everything in a try/catch to catch any initialization errors
|
15
|
-
try {
|
16
|
-
// Create a log file for debugging
|
17
|
-
const logFile = path.join(process.cwd(), "npx-standalone-debug.log");
|
18
|
-
fs.writeFileSync(
|
19
|
-
logFile,
|
20
|
-
`NPX standalone wrapper called at ${new Date().toISOString()}\n`
|
21
|
-
);
|
22
|
-
fs.appendFileSync(logFile, `Arguments: ${JSON.stringify(process.argv)}\n`);
|
23
|
-
fs.appendFileSync(logFile, `Working directory: ${process.cwd()}\n`);
|
24
|
-
fs.appendFileSync(logFile, `Node version: ${process.version}\n`);
|
25
|
-
|
26
|
-
// Get the docs directory from arguments or use default
|
27
|
-
let docsDir = path.join(process.cwd(), "docs");
|
28
|
-
const args = process.argv.slice(2);
|
29
|
-
|
30
|
-
fs.appendFileSync(logFile, `Processing args: ${JSON.stringify(args)}\n`);
|
31
|
-
|
32
|
-
if (args.length > 0) {
|
33
|
-
// Check if --docs-dir flag is used
|
34
|
-
const docsDirIndex = args.indexOf("--docs-dir");
|
35
|
-
if (docsDirIndex !== -1 && docsDirIndex + 1 < args.length) {
|
36
|
-
docsDir = args[docsDirIndex + 1];
|
37
|
-
fs.appendFileSync(logFile, `Found --docs-dir flag, using: ${docsDir}\n`);
|
38
|
-
} else {
|
39
|
-
// Otherwise, use the last argument if it looks like a path
|
40
|
-
const lastArg = args[args.length - 1];
|
41
|
-
if (!lastArg.startsWith("-")) {
|
42
|
-
docsDir = lastArg;
|
43
|
-
fs.appendFileSync(logFile, `Using last arg as docs dir: ${docsDir}\n`);
|
44
|
-
}
|
45
|
-
}
|
46
|
-
} else {
|
47
|
-
fs.appendFileSync(
|
48
|
-
logFile,
|
49
|
-
`No args provided, using default docs dir: ${docsDir}\n`
|
50
|
-
);
|
51
|
-
}
|
52
|
-
|
53
|
-
// Resolve the docs directory to an absolute path
|
54
|
-
docsDir = path.resolve(docsDir);
|
55
|
-
fs.appendFileSync(logFile, `Using docs directory: ${docsDir}\n`);
|
56
|
-
|
57
|
-
// Ensure the docs directory exists
|
58
|
-
if (!fs.existsSync(docsDir)) {
|
59
|
-
fs.appendFileSync(logFile, `Creating docs directory: ${docsDir}\n`);
|
60
|
-
try {
|
61
|
-
fs.mkdirSync(docsDir, { recursive: true });
|
62
|
-
fs.appendFileSync(logFile, `Successfully created docs directory\n`);
|
63
|
-
|
64
|
-
// Create a sample README.md file if the directory was just created
|
65
|
-
const readmePath = path.join(docsDir, "README.md");
|
66
|
-
if (!fs.existsSync(readmePath)) {
|
67
|
-
const sampleContent = `---
|
68
|
-
title: Documentation
|
69
|
-
description: Project documentation
|
70
|
-
---
|
71
|
-
|
72
|
-
# Documentation
|
73
|
-
|
74
|
-
This is the documentation directory for your project.
|
75
|
-
`;
|
76
|
-
fs.writeFileSync(readmePath, sampleContent);
|
77
|
-
console.log("Created sample README.md in", docsDir);
|
78
|
-
}
|
79
|
-
} catch (error) {
|
80
|
-
fs.appendFileSync(
|
81
|
-
logFile,
|
82
|
-
`Error creating docs directory: ${error.toString()}\n`
|
83
|
-
);
|
84
|
-
console.error(`Error creating docs directory: ${error}`);
|
85
|
-
process.exit(1);
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
console.log(
|
90
|
-
"MCP Documentation Service initialized with docs directory:",
|
91
|
-
docsDir
|
92
|
-
);
|
93
|
-
console.log("Directory will be created if it doesn't exist");
|
94
|
-
|
95
|
-
// Run the MCP Docs Service directly using the CLI
|
96
|
-
console.log("MCP Documentation Management Service started.");
|
97
|
-
console.log("Using docs directory:", docsDir);
|
98
|
-
console.log("Reading from stdin, writing results to stdout...");
|
99
|
-
|
100
|
-
// Create a simple MCP server that just echoes requests
|
101
|
-
process.stdin.setEncoding("utf8");
|
102
|
-
|
103
|
-
let buffer = "";
|
104
|
-
|
105
|
-
process.stdin.on("data", (chunk) => {
|
106
|
-
buffer += chunk;
|
107
|
-
|
108
|
-
try {
|
109
|
-
// Try to parse complete JSON objects from the buffer
|
110
|
-
const newlineIndex = buffer.indexOf("\n");
|
111
|
-
if (newlineIndex !== -1) {
|
112
|
-
const line = buffer.slice(0, newlineIndex);
|
113
|
-
buffer = buffer.slice(newlineIndex + 1);
|
114
|
-
|
115
|
-
const request = JSON.parse(line);
|
116
|
-
fs.appendFileSync(
|
117
|
-
logFile,
|
118
|
-
`Received request: ${JSON.stringify(request)}\n`
|
119
|
-
);
|
120
|
-
|
121
|
-
// Handle the request
|
122
|
-
if (request.method === "listTools") {
|
123
|
-
const response = {
|
124
|
-
id: request.id,
|
125
|
-
result: {
|
126
|
-
tools: [
|
127
|
-
{
|
128
|
-
name: "read_document",
|
129
|
-
description:
|
130
|
-
"Read a markdown document and extract its content and metadata",
|
131
|
-
inputSchema: {
|
132
|
-
type: "object",
|
133
|
-
properties: {
|
134
|
-
path: {
|
135
|
-
type: "string",
|
136
|
-
description: "Path to the markdown document",
|
137
|
-
},
|
138
|
-
},
|
139
|
-
required: ["path"],
|
140
|
-
},
|
141
|
-
},
|
142
|
-
{
|
143
|
-
name: "list_documents",
|
144
|
-
description: "List all markdown documents in a directory",
|
145
|
-
inputSchema: {
|
146
|
-
type: "object",
|
147
|
-
properties: {
|
148
|
-
basePath: {
|
149
|
-
type: "string",
|
150
|
-
description: "Base path to list documents from",
|
151
|
-
},
|
152
|
-
},
|
153
|
-
},
|
154
|
-
},
|
155
|
-
],
|
156
|
-
},
|
157
|
-
};
|
158
|
-
|
159
|
-
process.stdout.write(JSON.stringify(response) + "\n");
|
160
|
-
} else if (request.method === "callTool") {
|
161
|
-
// Respond with a simple success message
|
162
|
-
const response = {
|
163
|
-
id: request.id,
|
164
|
-
result: {
|
165
|
-
content: [
|
166
|
-
{
|
167
|
-
type: "text",
|
168
|
-
text: `Tool ${request.params.name} called successfully. The docs directory is ${docsDir}.`,
|
169
|
-
},
|
170
|
-
],
|
171
|
-
metadata: {
|
172
|
-
docsDir: docsDir,
|
173
|
-
},
|
174
|
-
},
|
175
|
-
};
|
176
|
-
|
177
|
-
process.stdout.write(JSON.stringify(response) + "\n");
|
178
|
-
}
|
179
|
-
}
|
180
|
-
} catch (error) {
|
181
|
-
fs.appendFileSync(
|
182
|
-
logFile,
|
183
|
-
`Error processing request: ${error.toString()}\n`
|
184
|
-
);
|
185
|
-
}
|
186
|
-
});
|
187
|
-
|
188
|
-
process.stdin.on("end", () => {
|
189
|
-
console.log("MCP Documentation Management Service terminated.");
|
190
|
-
process.exit(0);
|
191
|
-
});
|
192
|
-
|
193
|
-
// Handle process termination
|
194
|
-
process.on("SIGINT", () => {
|
195
|
-
console.log("\nMCP Documentation Management Service terminated.");
|
196
|
-
process.exit(0);
|
197
|
-
});
|
198
|
-
|
199
|
-
process.on("SIGTERM", () => {
|
200
|
-
console.log("\nMCP Documentation Management Service terminated.");
|
201
|
-
process.exit(0);
|
202
|
-
});
|
203
|
-
} catch (error) {
|
204
|
-
// Write to a fallback log file in case the main one couldn't be created
|
205
|
-
try {
|
206
|
-
fs.writeFileSync(
|
207
|
-
path.join(process.cwd(), "npx-standalone-error.log"),
|
208
|
-
`Fatal error in npx-standalone.cjs: ${error.toString()}\n${error.stack}\n`
|
209
|
-
);
|
210
|
-
} catch (e) {
|
211
|
-
// Last resort, just log to console
|
212
|
-
console.error(`Fatal error in npx-standalone.cjs: ${error.toString()}`);
|
213
|
-
console.error(error.stack);
|
214
|
-
}
|
215
|
-
process.exit(1);
|
216
|
-
}
|
package/npx-wrapper.js
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
/**
|
4
|
-
* NPX Wrapper for MCP Docs Service
|
5
|
-
*
|
6
|
-
* This script is a standalone wrapper that can be used directly with npx.
|
7
|
-
* It doesn't require any additional files from the package and will download
|
8
|
-
* and run the MCP Docs Service directly.
|
9
|
-
*/
|
10
|
-
|
11
|
-
import fs from "fs";
|
12
|
-
import path from "path";
|
13
|
-
import { spawn } from "child_process";
|
14
|
-
import { fileURLToPath } from "url";
|
15
|
-
|
16
|
-
// Wrap everything in a try/catch to catch any initialization errors
|
17
|
-
try {
|
18
|
-
// Create a log file for debugging
|
19
|
-
const logFile = path.join(process.cwd(), "npx-debug.log");
|
20
|
-
fs.writeFileSync(
|
21
|
-
logFile,
|
22
|
-
`NPX wrapper called at ${new Date().toISOString()}\n`
|
23
|
-
);
|
24
|
-
fs.appendFileSync(logFile, `Arguments: ${JSON.stringify(process.argv)}\n`);
|
25
|
-
fs.appendFileSync(logFile, `Working directory: ${process.cwd()}\n`);
|
26
|
-
|
27
|
-
// Get the docs directory from arguments or use default
|
28
|
-
let docsDir = path.join(process.cwd(), "docs");
|
29
|
-
const args = process.argv.slice(2);
|
30
|
-
|
31
|
-
fs.appendFileSync(logFile, `Processing args: ${JSON.stringify(args)}\n`);
|
32
|
-
|
33
|
-
if (args.length > 0) {
|
34
|
-
// Check if --docs-dir flag is used
|
35
|
-
const docsDirIndex = args.indexOf("--docs-dir");
|
36
|
-
if (docsDirIndex !== -1 && docsDirIndex + 1 < args.length) {
|
37
|
-
docsDir = args[docsDirIndex + 1];
|
38
|
-
fs.appendFileSync(logFile, `Found --docs-dir flag, using: ${docsDir}\n`);
|
39
|
-
} else {
|
40
|
-
// Otherwise, use the last argument if it looks like a path
|
41
|
-
const lastArg = args[args.length - 1];
|
42
|
-
if (!lastArg.startsWith("-")) {
|
43
|
-
docsDir = lastArg;
|
44
|
-
fs.appendFileSync(logFile, `Using last arg as docs dir: ${docsDir}\n`);
|
45
|
-
}
|
46
|
-
}
|
47
|
-
} else {
|
48
|
-
fs.appendFileSync(
|
49
|
-
logFile,
|
50
|
-
`No args provided, using default docs dir: ${docsDir}\n`
|
51
|
-
);
|
52
|
-
}
|
53
|
-
|
54
|
-
// Resolve the docs directory to an absolute path
|
55
|
-
docsDir = path.resolve(docsDir);
|
56
|
-
fs.appendFileSync(logFile, `Using docs directory: ${docsDir}\n`);
|
57
|
-
|
58
|
-
// Ensure the docs directory exists
|
59
|
-
if (!fs.existsSync(docsDir)) {
|
60
|
-
fs.appendFileSync(logFile, `Creating docs directory: ${docsDir}\n`);
|
61
|
-
try {
|
62
|
-
fs.mkdirSync(docsDir, { recursive: true });
|
63
|
-
fs.appendFileSync(logFile, `Successfully created docs directory\n`);
|
64
|
-
} catch (error) {
|
65
|
-
fs.appendFileSync(logFile, `Error creating docs directory: ${error}\n`);
|
66
|
-
console.error(`Error creating docs directory: ${error}`);
|
67
|
-
process.exit(1);
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
// Install the MCP Docs Service if not already installed
|
72
|
-
const packageName = "mcp-docs-service";
|
73
|
-
fs.appendFileSync(logFile, `Checking if ${packageName} is installed...\n`);
|
74
|
-
|
75
|
-
// Run the MCP Docs Service
|
76
|
-
fs.appendFileSync(
|
77
|
-
logFile,
|
78
|
-
`Running MCP Docs Service with docs dir: ${docsDir}\n`
|
79
|
-
);
|
80
|
-
|
81
|
-
// Use npx to run the service directly
|
82
|
-
const npxArgs = ["-y", packageName, "--docs-dir", docsDir];
|
83
|
-
fs.appendFileSync(
|
84
|
-
logFile,
|
85
|
-
`Running npx with args: ${JSON.stringify(npxArgs)}\n`
|
86
|
-
);
|
87
|
-
|
88
|
-
const child = spawn("npx", npxArgs, {
|
89
|
-
stdio: "inherit",
|
90
|
-
env: { ...process.env, MCP_STANDALONE_WRAPPER: "true" },
|
91
|
-
});
|
92
|
-
|
93
|
-
child.on("exit", (code) => {
|
94
|
-
fs.appendFileSync(logFile, `Child process exited with code ${code}\n`);
|
95
|
-
process.exit(code);
|
96
|
-
});
|
97
|
-
|
98
|
-
child.on("error", (err) => {
|
99
|
-
fs.appendFileSync(
|
100
|
-
logFile,
|
101
|
-
`Error spawning child process: ${err.message}\n`
|
102
|
-
);
|
103
|
-
console.error(`Error running MCP Docs Service: ${err.message}`);
|
104
|
-
process.exit(1);
|
105
|
-
});
|
106
|
-
} catch (error) {
|
107
|
-
// Write to a fallback log file in case the main one couldn't be created
|
108
|
-
try {
|
109
|
-
fs.writeFileSync(
|
110
|
-
path.join(process.cwd(), "npx-error.log"),
|
111
|
-
`Fatal error in npx-wrapper.js: ${error.message}\n${error.stack}\n`
|
112
|
-
);
|
113
|
-
} catch (e) {
|
114
|
-
// Last resort, just log to console
|
115
|
-
console.error(`Fatal error in npx-wrapper.js: ${error.message}`);
|
116
|
-
console.error(error.stack);
|
117
|
-
}
|
118
|
-
process.exit(1);
|
119
|
-
}
|