@meldocio/mcp-stdio-proxy 1.0.2 → 1.0.4
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 +46 -1
- package/bin/meldoc-mcp-proxy.js +50 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,9 +107,11 @@ echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | \
|
|
|
107
107
|
- ✅ JSON-RPC 2.0 protocol
|
|
108
108
|
- ✅ Single and batch requests
|
|
109
109
|
- ✅ Proper error handling with JSON-RPC error codes
|
|
110
|
-
- ✅ Request timeout handling (
|
|
110
|
+
- ✅ Request timeout handling (25 seconds)
|
|
111
111
|
- ✅ Network error recovery
|
|
112
112
|
- ✅ Line-by-line processing for streaming
|
|
113
|
+
- ✅ Automatic support for all MCP tools (including `server_info`)
|
|
114
|
+
- ✅ Metadata (`_meta`) in responses for better context
|
|
113
115
|
|
|
114
116
|
## JSON-RPC Error Codes
|
|
115
117
|
|
|
@@ -122,6 +124,49 @@ The proxy uses standard JSON-RPC 2.0 error codes:
|
|
|
122
124
|
- `-32603`: Internal error (network errors, timeouts, etc.)
|
|
123
125
|
- `-32000`: Server error (HTTP 4xx/5xx responses)
|
|
124
126
|
|
|
127
|
+
## Available Tools
|
|
128
|
+
|
|
129
|
+
The proxy automatically supports all tools provided by the meldoc MCP API, including:
|
|
130
|
+
|
|
131
|
+
- **`server_info`** - Get information about the server configuration, available projects, and token capabilities
|
|
132
|
+
- **`docs_list`** - List available documentation
|
|
133
|
+
- **`docs_get`** - Get specific documentation content
|
|
134
|
+
- And other tools as provided by the API
|
|
135
|
+
|
|
136
|
+
### Example: Using `server_info`
|
|
137
|
+
|
|
138
|
+
You can get server information using the `server_info` tool:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
echo '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"server_info","arguments":{}}}' | \
|
|
142
|
+
MELDOC_MCP_TOKEN=your_token_here npx @meldocio/mcp-stdio-proxy
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The response includes:
|
|
146
|
+
- Server name (from token)
|
|
147
|
+
- Token description (if provided)
|
|
148
|
+
- Available projects with IDs, names, and aliases
|
|
149
|
+
- Token capabilities (read, update, create, delete)
|
|
150
|
+
- Usage hints
|
|
151
|
+
|
|
152
|
+
### Response Metadata
|
|
153
|
+
|
|
154
|
+
All tool responses now include a `_meta` field with contextual information:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"items": [...],
|
|
159
|
+
"_meta": {
|
|
160
|
+
"server": "My Token",
|
|
161
|
+
"projects": ["Frontend Docs", "Backend API"],
|
|
162
|
+
"capabilities": ["read"],
|
|
163
|
+
"hint": "Read permission required for this operation"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
This metadata helps AI assistants understand the context and limitations of the current token.
|
|
169
|
+
|
|
125
170
|
## Troubleshooting
|
|
126
171
|
|
|
127
172
|
### Error: MELDOC_MCP_TOKEN environment variable is required
|
package/bin/meldoc-mcp-proxy.js
CHANGED
|
@@ -18,7 +18,7 @@ const JSON_RPC_ERROR_CODES = {
|
|
|
18
18
|
const token = process.env.MELDOC_MCP_TOKEN;
|
|
19
19
|
const apiUrl = process.env.MELDOC_API_URL || 'https://api.meldoc.io';
|
|
20
20
|
const rpcEndpoint = `${apiUrl}/mcp/v1/rpc`;
|
|
21
|
-
const REQUEST_TIMEOUT =
|
|
21
|
+
const REQUEST_TIMEOUT = 25000; // 25 seconds (less than Claude Desktop's 30s timeout)
|
|
22
22
|
|
|
23
23
|
// Validate token
|
|
24
24
|
if (!token) {
|
|
@@ -86,8 +86,11 @@ function handleLine(line) {
|
|
|
86
86
|
const request = JSON.parse(line);
|
|
87
87
|
handleRequest(request);
|
|
88
88
|
} catch (parseError) {
|
|
89
|
-
// Invalid JSON -
|
|
90
|
-
|
|
89
|
+
// Invalid JSON - try to extract id from the raw line if possible
|
|
90
|
+
// For parse errors, we can't reliably get the id, so we skip the response
|
|
91
|
+
// to avoid Zod validation errors in Claude Desktop (it doesn't accept id: null)
|
|
92
|
+
// This is acceptable per JSON-RPC spec - parse errors can be ignored if id is unknown
|
|
93
|
+
console.error(`Parse error: ${parseError.message}`, { to: 'stderr' });
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -131,11 +134,16 @@ async function handleRequest(request) {
|
|
|
131
134
|
const method = req.method;
|
|
132
135
|
if (method === 'initialize') {
|
|
133
136
|
handleInitialize(req);
|
|
134
|
-
} else if (method === 'initialized') {
|
|
137
|
+
} else if (method === 'initialized' || method === 'notifications/initialized') {
|
|
138
|
+
// Notification - no response needed
|
|
139
|
+
continue;
|
|
140
|
+
} else if (method === 'notifications/cancelled') {
|
|
135
141
|
// Notification - no response needed
|
|
136
142
|
continue;
|
|
137
143
|
} else if (method === 'ping') {
|
|
138
144
|
handlePing(req);
|
|
145
|
+
} else if (method === 'resources/list') {
|
|
146
|
+
handleResourcesList(req);
|
|
139
147
|
} else {
|
|
140
148
|
// Forward to backend
|
|
141
149
|
await processSingleRequest(req);
|
|
@@ -157,15 +165,22 @@ async function handleRequest(request) {
|
|
|
157
165
|
if (method === 'initialize') {
|
|
158
166
|
handleInitialize(request);
|
|
159
167
|
return;
|
|
160
|
-
} else if (method === 'initialized') {
|
|
168
|
+
} else if (method === 'initialized' || method === 'notifications/initialized') {
|
|
161
169
|
// Notification - no response needed per MCP spec
|
|
162
170
|
return;
|
|
171
|
+
} else if (method === 'notifications/cancelled') {
|
|
172
|
+
// Notification - no response needed
|
|
173
|
+
return;
|
|
163
174
|
} else if (method === 'ping') {
|
|
164
175
|
handlePing(request);
|
|
165
176
|
return;
|
|
177
|
+
} else if (method === 'resources/list') {
|
|
178
|
+
// Return empty resources list (resources not supported yet)
|
|
179
|
+
handleResourcesList(request);
|
|
180
|
+
return;
|
|
166
181
|
}
|
|
167
182
|
|
|
168
|
-
// All other methods (tools/*,
|
|
183
|
+
// All other methods (tools/*, etc.) are forwarded to backend
|
|
169
184
|
await processSingleRequest(request);
|
|
170
185
|
}
|
|
171
186
|
|
|
@@ -185,7 +200,7 @@ function handleInitialize(request) {
|
|
|
185
200
|
},
|
|
186
201
|
serverInfo: {
|
|
187
202
|
name: '@meldocio/mcp-stdio-proxy',
|
|
188
|
-
version: '1.0.
|
|
203
|
+
version: '1.0.2'
|
|
189
204
|
}
|
|
190
205
|
}
|
|
191
206
|
};
|
|
@@ -212,6 +227,25 @@ function handlePing(request) {
|
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Handle resources/list method
|
|
232
|
+
* Returns empty list as resources are not supported yet
|
|
233
|
+
*/
|
|
234
|
+
function handleResourcesList(request) {
|
|
235
|
+
const response = {
|
|
236
|
+
jsonrpc: '2.0',
|
|
237
|
+
id: request.id,
|
|
238
|
+
result: {
|
|
239
|
+
resources: []
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
process.stdout.write(JSON.stringify(response) + '\n');
|
|
244
|
+
if (process.stdout.isTTY) {
|
|
245
|
+
process.stdout.flush();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
215
249
|
/**
|
|
216
250
|
* Process a single JSON-RPC request
|
|
217
251
|
* Forwards the request to the backend MCP API
|
|
@@ -302,9 +336,17 @@ async function processSingleRequest(request) {
|
|
|
302
336
|
* Send JSON-RPC error response
|
|
303
337
|
*/
|
|
304
338
|
function sendError(id, code, message) {
|
|
339
|
+
// Only send error response if id is defined (not for notifications)
|
|
340
|
+
// Claude Desktop's Zod schema doesn't accept null for id
|
|
341
|
+
if (id === undefined || id === null) {
|
|
342
|
+
// For notifications or parse errors without id, don't send response
|
|
343
|
+
// or send without id field
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
305
347
|
const errorResponse = {
|
|
306
348
|
jsonrpc: '2.0',
|
|
307
|
-
id: id
|
|
349
|
+
id: id,
|
|
308
350
|
error: {
|
|
309
351
|
code: code,
|
|
310
352
|
message: message
|