mcp-docs-service 0.3.8 → 0.3.9
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/index.js +1 -1
- package/npx-wrapper.cjs +90 -42
- package/package.json +1 -1
package/dist/index.js
CHANGED
package/npx-wrapper.cjs
CHANGED
@@ -47,16 +47,56 @@ const logToFile = (message) => {
|
|
47
47
|
logToFile(`Process arguments: ${JSON.stringify(process.argv)}`);
|
48
48
|
logToFile(`Working directory: ${process.cwd()}`);
|
49
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)}`);
|
50
53
|
|
51
54
|
// Find the path to the actual service script
|
52
55
|
// When run via npx, the script will be in the package's directory
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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}`);
|
60
100
|
process.exit(1);
|
61
101
|
}
|
62
102
|
|
@@ -74,39 +114,47 @@ const env = {
|
|
74
114
|
|
75
115
|
// Create a child process with piped stdio
|
76
116
|
// This is critical for MCP - we need to control stdin/stdout directly
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
})
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
// Pipe
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
//
|
102
|
-
child.
|
103
|
-
|
104
|
-
process
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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}`);
|
111
159
|
process.exit(1);
|
112
|
-
}
|
160
|
+
}
|
package/package.json
CHANGED