okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221merge f-split-s4b 0edf5cb9f (Harness in the app chat, Manual approvals, request slots) into f-split-inta16109803

main
1.3 KiB18 linesraw
1// A minimal MCP server over stdio (newline-delimited JSON-RPC), for the tool-server test. One tool, `shout`: it upper-cases
2// its text and reports whether the secret from the environment arrived, WITHOUT printing the secret.
3import { createInterface } from 'node:readline';
4
5const send = message => process.stdout.write(`${JSON.stringify({ jsonrpc: '2.0', ...message })}\n`);
6createInterface({ input: process.stdin }).on('line', line => {
7  let m; try { m = JSON.parse(line); } catch { return; }
8  if (m.method === 'initialize') {
9    send({ id: m.id, result: { protocolVersion: m.params?.protocolVersion ?? '2025-06-18', capabilities: { tools: { listChanged: false } }, serverInfo: { name: 'mini', version: '1.0.0' } } });
10  } else if (m.method === 'tools/list') {
11    send({ id: m.id, result: { tools: [{ name: 'shout', description: 'Upper-case the text.', inputSchema: { type: 'object', properties: { text: { type: 'string' } }, required: ['text'] } }] } });
12  } else if (m.method === 'tools/call') {
13    const text = String(m.params?.arguments?.text ?? '');
14    send({ id: m.id, result: { content: [{ type: 'text', text: `${text.toUpperCase()}|token:${process.env.DEMO_TOKEN ? 'set' : 'missing'}` }] } });
15  } else if (m.id !== undefined && m.method) {
16    send({ id: m.id, result: {} });
17  }
18});