MCP server on the official SDK, over stdio or HTTP
scripts/mcp.js registers the same tools on @modelcontextprotocol/server (2.4.0, with @modelcontextprotocol/node 2.1.2 for node:http; dev dependencies, pinned) instead of its own JSON-RPC loop. stdio works as before; --http [HOST:]PORT serves Streamable HTTP at /mcp, on loopback unless told otherwise. Over HTTP every request's Host must be an address of this machine (or --allow-host), an Origin other than localhost is refused, and a bearer token (SOT_MCP_TOKEN or --token-file) is optional; bound beyond loopback without one, the server warns. load_save and export_save take JSON only there, or files under --save-dir and nowhere else. Calls from every client run one at a time, in order.
This commit is contained in:
parent
5b76685e5c
commit
2526dd458d
11 changed files with 467 additions and 63 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// The MCP server (scripts/mcp.js): an AI client plays, inspects and debugs the game through typed tools.
|
||||
// The MCP server (scripts/mcp.js): an AI client plays, inspects and debugs the game through typed tools. Over stdio
|
||||
// here; tests/mcp-http.test.js has the HTTP transport.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
|
|
@ -27,7 +28,7 @@ test('speaks MCP over stdio: initialize, list tools, call one, and errors as err
|
|||
assert.equal(init.result.protocolVersion, '2025-06-18');
|
||||
assert.equal(init.result.serverInfo.name, 'seriesoftubes');
|
||||
assert.ok(init.result.capabilities.tools);
|
||||
assert.equal((await ask({ id: 9, method: 'initialize', params: { protocolVersion: '1999-01-01' } })).result.protocolVersion, '2025-11-25', 'an unknown version gets the newest');
|
||||
assert.equal((await ask({ id: 9, method: 'initialize', params: { protocolVersion: '1999-01-01', capabilities: {}, clientInfo: { name: 'test', version: '1' } } })).result.protocolVersion, '2025-11-25', 'an unknown version gets the newest');
|
||||
await ask({ method: 'notifications/initialized' });
|
||||
const list = await ask({ id: 2, method: 'tools/list' });
|
||||
const names = list.result.tools.map((t) => t.name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue