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 CHANGED
@@ -453,7 +453,7 @@ async function checkDocumentationHealth(basePath) {
453
453
  // Server setup
454
454
  const server = new Server({
455
455
  name: "mcp-docs-service",
456
- version: "0.3.8",
456
+ version: "0.3.9",
457
457
  }, {
458
458
  capabilities: {
459
459
  tools: {},
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
- const servicePath = path.resolve(path.join(__dirname, "dist", "index.js"));
54
- logToFile(`Service path: ${servicePath}`);
55
-
56
- // Check if the service script exists
57
- if (!fs.existsSync(servicePath)) {
58
- logToFile(`ERROR: Service script not found at ${servicePath}`);
59
- console.error(`ERROR: Service script not found at ${servicePath}`);
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
- const child = spawn("node", [servicePath, ...args], {
78
- stdio: ["pipe", "pipe", "pipe"],
79
- env,
80
- });
81
-
82
- // Redirect child's stderr to our stderr
83
- child.stderr.on("data", (data) => {
84
- process.stderr.write(data);
85
-
86
- // Also log to file for debugging
87
- try {
88
- logToFile(`STDERR: ${data.toString()}`);
89
- } catch (err) {
90
- // Ignore errors
91
- }
92
- });
93
-
94
- // Pipe our stdin directly to child's stdin
95
- process.stdin.pipe(child.stdin);
96
-
97
- // Pipe child's stdout directly to our stdout
98
- // This is the critical part - we don't want to modify the JSON communication
99
- child.stdout.pipe(process.stdout);
100
-
101
- // Handle process exit
102
- child.on("exit", (code) => {
103
- logToFile(`Child process exited with code ${code}`);
104
- process.exit(code || 0);
105
- });
106
-
107
- // Handle errors
108
- child.on("error", (err) => {
109
- logToFile(`Error spawning child process: ${err.message}`);
110
- console.error(`Error spawning MCP Docs Service: ${err.message}`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-docs-service",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "MCP Documentation Service - A Model Context Protocol implementation for documentation management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",