@mctx-ai/mcp-dev 0.4.0 → 0.5.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/package.json +2 -2
- package/src/server.js +2 -85
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mctx-ai/mcp-dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Local development server for @mctx-ai/mcp-server with hot reload",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/cli.js",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"provenance": true
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@mctx-ai/mcp-server": "0.
|
|
43
|
+
"@mctx-ai/mcp-server": "0.5.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
package/src/server.js
CHANGED
|
@@ -48,52 +48,6 @@ function logFramework(message, color = colors.reset) {
|
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/**
|
|
52
|
-
* Handle MCP initialize handshake
|
|
53
|
-
* This is normally handled by the MCP client (Claude Desktop), but we need to
|
|
54
|
-
* handle it locally for development.
|
|
55
|
-
*/
|
|
56
|
-
function handleInitialize(rpcRequest) {
|
|
57
|
-
const { method, params = {} } = rpcRequest;
|
|
58
|
-
|
|
59
|
-
if (method === "initialize") {
|
|
60
|
-
// Respond with server capabilities
|
|
61
|
-
return {
|
|
62
|
-
jsonrpc: "2.0",
|
|
63
|
-
id: rpcRequest.id,
|
|
64
|
-
result: {
|
|
65
|
-
protocolVersion: "2024-11-05",
|
|
66
|
-
capabilities: {
|
|
67
|
-
tools: {},
|
|
68
|
-
resources: {},
|
|
69
|
-
prompts: {},
|
|
70
|
-
logging: {},
|
|
71
|
-
},
|
|
72
|
-
serverInfo: {
|
|
73
|
-
name: "mctx-dev",
|
|
74
|
-
version: "0.1.0",
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (method === "initialized") {
|
|
81
|
-
// Fix #3: Return special marker for notifications (no response per JSON-RPC 2.0)
|
|
82
|
-
return { _notification: true };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (method === "ping") {
|
|
86
|
-
// Respond to ping
|
|
87
|
-
return {
|
|
88
|
-
jsonrpc: "2.0",
|
|
89
|
-
id: rpcRequest.id,
|
|
90
|
-
result: {},
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
51
|
/**
|
|
98
52
|
* Extract method name and arguments for logging
|
|
99
53
|
*/
|
|
@@ -364,45 +318,8 @@ export async function startDevServer(entryUrl, port) {
|
|
|
364
318
|
}
|
|
365
319
|
|
|
366
320
|
try {
|
|
367
|
-
//
|
|
368
|
-
|
|
369
|
-
if (initResponse !== null) {
|
|
370
|
-
const elapsed = Date.now() - startTime;
|
|
371
|
-
|
|
372
|
-
// Fix #3: For notifications (initialized), send 204 No Content
|
|
373
|
-
if (initResponse._notification === true) {
|
|
374
|
-
res.writeHead(204);
|
|
375
|
-
res.end();
|
|
376
|
-
log(
|
|
377
|
-
`${colors.green}←${colors.reset} 204 (${elapsed}ms)`,
|
|
378
|
-
colors.dim,
|
|
379
|
-
);
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// Fix #5: Include app capabilities if available
|
|
384
|
-
if (rpcRequest.method === "initialize" && app) {
|
|
385
|
-
const capabilities = initResponse.result.capabilities;
|
|
386
|
-
|
|
387
|
-
// Merge app capabilities if exposed
|
|
388
|
-
if (app.tools && typeof app.tools.list === "function") {
|
|
389
|
-
capabilities.tools = app.tools.capabilities || {};
|
|
390
|
-
}
|
|
391
|
-
if (app.resources && typeof app.resources.list === "function") {
|
|
392
|
-
capabilities.resources = app.resources.capabilities || {};
|
|
393
|
-
}
|
|
394
|
-
if (app.prompts && typeof app.prompts.list === "function") {
|
|
395
|
-
capabilities.prompts = app.prompts.capabilities || {};
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
400
|
-
res.end(JSON.stringify(initResponse));
|
|
401
|
-
log(`${colors.green}←${colors.reset} 200 (${elapsed}ms)`, colors.dim);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Delegate to app's fetch handler
|
|
321
|
+
// Delegate all requests to app's fetch handler (including initialize)
|
|
322
|
+
// The core SDK now handles initialize, initialized, and ping
|
|
406
323
|
const request = createRequest(rpcRequest);
|
|
407
324
|
const response = await app.fetch(request, {}, {});
|
|
408
325
|
|