mcp-docs-service 0.3.9 → 0.4.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/dist/cli/bin.d.ts +8 -0
- package/dist/cli/bin.js +133 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/handlers/docs.d.ts +26 -0
- package/dist/handlers/docs.js +513 -0
- package/dist/handlers/docs.js.map +1 -0
- package/dist/handlers/documents.js +282 -0
- package/dist/handlers/file.d.ts +32 -0
- package/dist/handlers/file.js +222 -0
- package/dist/handlers/file.js.map +1 -0
- package/dist/handlers/health.js +196 -0
- package/dist/handlers/index.d.ts +1 -0
- package/dist/handlers/index.js +8 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/handlers/navigation.js +128 -0
- package/dist/index.js +108 -550
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/tools.d.ts +164 -0
- package/dist/schemas/tools.js +47 -0
- package/dist/schemas/tools.js.map +1 -0
- package/dist/types/docs.d.ts +74 -0
- package/dist/types/docs.js +1 -0
- package/dist/types/docs.js.map +1 -0
- package/dist/types/file.d.ts +21 -0
- package/dist/types/file.js +2 -0
- package/dist/types/file.js.map +1 -0
- package/dist/types/index.d.ts +44 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/tools.d.ts +11 -0
- package/dist/types/tools.js +1 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/file.d.ts +24 -0
- package/dist/utils/file.js +94 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logging.js +27 -0
- package/dist/utils/path.d.ts +16 -0
- package/dist/utils/path.js +69 -0
- package/dist/utils/path.js.map +1 -0
- package/package.json +5 -9
- package/cursor-wrapper.cjs +0 -111
- package/npx-wrapper.cjs +0 -160
package/package.json
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"name": "mcp-docs-service",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.4.0",
|
4
4
|
"description": "MCP Documentation Service - A Model Context Protocol implementation for documentation management",
|
5
5
|
"type": "module",
|
6
6
|
"main": "dist/index.js",
|
7
7
|
"bin": {
|
8
|
-
"mcp-docs-service": "dist/index.js"
|
9
|
-
"mcp-docs-service-cursor": "cursor-wrapper.cjs",
|
10
|
-
"mcp-docs-service-npx": "npx-wrapper.cjs"
|
8
|
+
"mcp-docs-service": "dist/index.js"
|
11
9
|
},
|
12
10
|
"files": [
|
13
11
|
"dist",
|
14
12
|
"README.md",
|
15
|
-
"LICENSE"
|
16
|
-
"cursor-wrapper.cjs",
|
17
|
-
"npx-wrapper.cjs"
|
13
|
+
"LICENSE"
|
18
14
|
],
|
19
15
|
"scripts": {
|
20
16
|
"build": "tsc",
|
@@ -36,7 +32,7 @@
|
|
36
32
|
"author": "",
|
37
33
|
"license": "MIT",
|
38
34
|
"dependencies": {
|
39
|
-
"@modelcontextprotocol/sdk": "^
|
35
|
+
"@modelcontextprotocol/sdk": "^1.7.0",
|
40
36
|
"diff": "^5.1.0",
|
41
37
|
"glob": "^10.3.10",
|
42
38
|
"minimatch": "^9.0.3",
|
@@ -51,7 +47,7 @@
|
|
51
47
|
"eslint": "^8.56.0",
|
52
48
|
"ts-node": "^10.9.2",
|
53
49
|
"typescript": "^5.3.3",
|
54
|
-
"vitest": "^
|
50
|
+
"vitest": "^3.0.8"
|
55
51
|
},
|
56
52
|
"engines": {
|
57
53
|
"node": ">=18.0.0"
|
package/cursor-wrapper.cjs
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
/**
|
4
|
-
* MCP Cursor Wrapper
|
5
|
-
*
|
6
|
-
* This script is a wrapper for the MCP Docs Service that ensures proper stdio handling for Cursor.
|
7
|
-
* It redirects all console.log output to stderr to avoid interfering with the JSON communication.
|
8
|
-
*/
|
9
|
-
|
10
|
-
const { spawn } = require("child_process");
|
11
|
-
const path = require("path");
|
12
|
-
const fs = require("fs");
|
13
|
-
|
14
|
-
// Create a debug log file
|
15
|
-
const logDir = path.join(
|
16
|
-
process.env.HOME || process.env.USERPROFILE,
|
17
|
-
".mcp-docs-service"
|
18
|
-
);
|
19
|
-
try {
|
20
|
-
if (!fs.existsSync(logDir)) {
|
21
|
-
fs.mkdirSync(logDir, { recursive: true });
|
22
|
-
}
|
23
|
-
} catch (err) {
|
24
|
-
// Ignore errors creating log directory
|
25
|
-
}
|
26
|
-
|
27
|
-
const logFile = path.join(logDir, "cursor-debug.log");
|
28
|
-
try {
|
29
|
-
fs.writeFileSync(
|
30
|
-
logFile,
|
31
|
-
`MCP Cursor Wrapper called at ${new Date().toISOString()}\n`
|
32
|
-
);
|
33
|
-
} catch (err) {
|
34
|
-
// Ignore errors writing to log file
|
35
|
-
}
|
36
|
-
|
37
|
-
// Helper function to log to the file
|
38
|
-
const logToFile = (message) => {
|
39
|
-
try {
|
40
|
-
fs.appendFileSync(logFile, `${message}\n`);
|
41
|
-
} catch (err) {
|
42
|
-
// Ignore errors writing to log file
|
43
|
-
}
|
44
|
-
};
|
45
|
-
|
46
|
-
// Log debug information
|
47
|
-
logToFile(`Process arguments: ${JSON.stringify(process.argv)}`);
|
48
|
-
logToFile(`Working directory: ${process.cwd()}`);
|
49
|
-
logToFile(`Script directory: ${__dirname}`);
|
50
|
-
|
51
|
-
// Find the path to the actual service script
|
52
|
-
const servicePath = path.resolve(path.join(__dirname, "dist", "index.js"));
|
53
|
-
logToFile(`Service path: ${servicePath}`);
|
54
|
-
|
55
|
-
// Check if the service script exists
|
56
|
-
if (!fs.existsSync(servicePath)) {
|
57
|
-
logToFile(`ERROR: Service script not found at ${servicePath}`);
|
58
|
-
console.error(`ERROR: Service script not found at ${servicePath}`);
|
59
|
-
process.exit(1);
|
60
|
-
}
|
61
|
-
|
62
|
-
// Get command line arguments, skipping the first two (node and script path)
|
63
|
-
const args = process.argv.slice(2);
|
64
|
-
logToFile(`Command line arguments: ${JSON.stringify(args)}`);
|
65
|
-
|
66
|
-
// Set environment variables
|
67
|
-
const env = {
|
68
|
-
...process.env,
|
69
|
-
MCP_CURSOR_WRAPPER: "true",
|
70
|
-
// Redirect console.log to stderr
|
71
|
-
NODE_OPTIONS: `${process.env.NODE_OPTIONS || ""} --redirect-warnings=stderr`,
|
72
|
-
};
|
73
|
-
|
74
|
-
// Create a child process with piped stdio
|
75
|
-
// This is critical for Cursor - we need to control stdin/stdout directly
|
76
|
-
const child = spawn("node", [servicePath, ...args], {
|
77
|
-
stdio: ["pipe", "pipe", "pipe"],
|
78
|
-
env,
|
79
|
-
});
|
80
|
-
|
81
|
-
// Redirect child's stderr to our stderr
|
82
|
-
child.stderr.on("data", (data) => {
|
83
|
-
process.stderr.write(data);
|
84
|
-
|
85
|
-
// Also log to file for debugging
|
86
|
-
try {
|
87
|
-
logToFile(`STDERR: ${data.toString()}`);
|
88
|
-
} catch (err) {
|
89
|
-
// Ignore errors
|
90
|
-
}
|
91
|
-
});
|
92
|
-
|
93
|
-
// Pipe our stdin directly to child's stdin
|
94
|
-
process.stdin.pipe(child.stdin);
|
95
|
-
|
96
|
-
// Pipe child's stdout directly to our stdout
|
97
|
-
// This is the critical part - we don't want to modify the JSON communication
|
98
|
-
child.stdout.pipe(process.stdout);
|
99
|
-
|
100
|
-
// Handle process exit
|
101
|
-
child.on("exit", (code) => {
|
102
|
-
logToFile(`Child process exited with code ${code}`);
|
103
|
-
process.exit(code || 0);
|
104
|
-
});
|
105
|
-
|
106
|
-
// Handle errors
|
107
|
-
child.on("error", (err) => {
|
108
|
-
logToFile(`Error spawning child process: ${err.message}`);
|
109
|
-
console.error(`Error spawning MCP Docs Service: ${err.message}`);
|
110
|
-
process.exit(1);
|
111
|
-
});
|
package/npx-wrapper.cjs
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
/**
|
4
|
-
* MCP NPX Wrapper
|
5
|
-
*
|
6
|
-
* This script is a wrapper for the MCP Docs Service that ensures proper stdio handling when run via npx.
|
7
|
-
* It redirects all console.log output to stderr to avoid interfering with the JSON communication.
|
8
|
-
*/
|
9
|
-
|
10
|
-
const { spawn } = require("child_process");
|
11
|
-
const path = require("path");
|
12
|
-
const fs = require("fs");
|
13
|
-
|
14
|
-
// Create a debug log file
|
15
|
-
const logDir = path.join(
|
16
|
-
process.env.HOME || process.env.USERPROFILE,
|
17
|
-
".mcp-docs-service"
|
18
|
-
);
|
19
|
-
try {
|
20
|
-
if (!fs.existsSync(logDir)) {
|
21
|
-
fs.mkdirSync(logDir, { recursive: true });
|
22
|
-
}
|
23
|
-
} catch (err) {
|
24
|
-
// Ignore errors creating log directory
|
25
|
-
}
|
26
|
-
|
27
|
-
const logFile = path.join(logDir, "npx-debug.log");
|
28
|
-
try {
|
29
|
-
fs.writeFileSync(
|
30
|
-
logFile,
|
31
|
-
`MCP NPX Wrapper called at ${new Date().toISOString()}\n`
|
32
|
-
);
|
33
|
-
} catch (err) {
|
34
|
-
// Ignore errors writing to log file
|
35
|
-
}
|
36
|
-
|
37
|
-
// Helper function to log to the file
|
38
|
-
const logToFile = (message) => {
|
39
|
-
try {
|
40
|
-
fs.appendFileSync(logFile, `${message}\n`);
|
41
|
-
} catch (err) {
|
42
|
-
// Ignore errors writing to log file
|
43
|
-
}
|
44
|
-
};
|
45
|
-
|
46
|
-
// Log debug information
|
47
|
-
logToFile(`Process arguments: ${JSON.stringify(process.argv)}`);
|
48
|
-
logToFile(`Working directory: ${process.cwd()}`);
|
49
|
-
logToFile(`Script directory: ${__dirname}`);
|
50
|
-
logToFile(`Node version: ${process.version}`);
|
51
|
-
logToFile(`Platform: ${process.platform}`);
|
52
|
-
logToFile(`Environment variables: ${JSON.stringify(process.env.PATH)}`);
|
53
|
-
|
54
|
-
// Find the path to the actual service script
|
55
|
-
// When run via npx, the script will be in the package's directory
|
56
|
-
let servicePath;
|
57
|
-
try {
|
58
|
-
servicePath = path.resolve(path.join(__dirname, "dist", "index.js"));
|
59
|
-
logToFile(`Service path: ${servicePath}`);
|
60
|
-
|
61
|
-
// Check if the service script exists
|
62
|
-
if (!fs.existsSync(servicePath)) {
|
63
|
-
logToFile(`ERROR: Service script not found at ${servicePath}`);
|
64
|
-
|
65
|
-
// Try to find the script in the current directory
|
66
|
-
const localPath = path.resolve(
|
67
|
-
path.join(process.cwd(), "dist", "index.js")
|
68
|
-
);
|
69
|
-
logToFile(`Trying local path: ${localPath}`);
|
70
|
-
|
71
|
-
if (fs.existsSync(localPath)) {
|
72
|
-
servicePath = localPath;
|
73
|
-
logToFile(`Found service script at local path: ${servicePath}`);
|
74
|
-
} else {
|
75
|
-
// Try to find the script in node_modules
|
76
|
-
const nodeModulesPath = path.resolve(
|
77
|
-
path.join(
|
78
|
-
process.cwd(),
|
79
|
-
"node_modules",
|
80
|
-
"mcp-docs-service",
|
81
|
-
"dist",
|
82
|
-
"index.js"
|
83
|
-
)
|
84
|
-
);
|
85
|
-
logToFile(`Trying node_modules path: ${nodeModulesPath}`);
|
86
|
-
|
87
|
-
if (fs.existsSync(nodeModulesPath)) {
|
88
|
-
servicePath = nodeModulesPath;
|
89
|
-
logToFile(`Found service script in node_modules: ${servicePath}`);
|
90
|
-
} else {
|
91
|
-
logToFile(`ERROR: Could not find service script`);
|
92
|
-
console.error(`ERROR: Could not find service script`);
|
93
|
-
process.exit(1);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
|
-
} catch (err) {
|
98
|
-
logToFile(`ERROR finding service path: ${err.message}`);
|
99
|
-
console.error(`ERROR finding service path: ${err.message}`);
|
100
|
-
process.exit(1);
|
101
|
-
}
|
102
|
-
|
103
|
-
// Get command line arguments, skipping the first two (node and script path)
|
104
|
-
const args = process.argv.slice(2);
|
105
|
-
logToFile(`Command line arguments: ${JSON.stringify(args)}`);
|
106
|
-
|
107
|
-
// Set environment variables
|
108
|
-
const env = {
|
109
|
-
...process.env,
|
110
|
-
MCP_NPX_WRAPPER: "true",
|
111
|
-
// Redirect console.log to stderr
|
112
|
-
NODE_OPTIONS: `${process.env.NODE_OPTIONS || ""} --redirect-warnings=stderr`,
|
113
|
-
};
|
114
|
-
|
115
|
-
// Create a child process with piped stdio
|
116
|
-
// This is critical for MCP - we need to control stdin/stdout directly
|
117
|
-
try {
|
118
|
-
logToFile(`Spawning child process: node ${servicePath} ${args.join(" ")}`);
|
119
|
-
|
120
|
-
const child = spawn("node", [servicePath, ...args], {
|
121
|
-
stdio: ["pipe", "pipe", "pipe"],
|
122
|
-
env,
|
123
|
-
});
|
124
|
-
|
125
|
-
// Redirect child's stderr to our stderr
|
126
|
-
child.stderr.on("data", (data) => {
|
127
|
-
process.stderr.write(data);
|
128
|
-
|
129
|
-
// Also log to file for debugging
|
130
|
-
try {
|
131
|
-
logToFile(`STDERR: ${data.toString()}`);
|
132
|
-
} catch (err) {
|
133
|
-
// Ignore errors
|
134
|
-
}
|
135
|
-
});
|
136
|
-
|
137
|
-
// Pipe our stdin directly to child's stdin
|
138
|
-
process.stdin.pipe(child.stdin);
|
139
|
-
|
140
|
-
// Pipe child's stdout directly to our stdout
|
141
|
-
// This is the critical part - we don't want to modify the JSON communication
|
142
|
-
child.stdout.pipe(process.stdout);
|
143
|
-
|
144
|
-
// Handle process exit
|
145
|
-
child.on("exit", (code) => {
|
146
|
-
logToFile(`Child process exited with code ${code}`);
|
147
|
-
process.exit(code || 0);
|
148
|
-
});
|
149
|
-
|
150
|
-
// Handle errors
|
151
|
-
child.on("error", (err) => {
|
152
|
-
logToFile(`Error spawning child process: ${err.message}`);
|
153
|
-
console.error(`Error spawning MCP Docs Service: ${err.message}`);
|
154
|
-
process.exit(1);
|
155
|
-
});
|
156
|
-
} catch (err) {
|
157
|
-
logToFile(`ERROR spawning child process: ${err.message}`);
|
158
|
-
console.error(`ERROR spawning child process: ${err.message}`);
|
159
|
-
process.exit(1);
|
160
|
-
}
|