MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / handle

Function handle

e2e/local/fixtures/stdio-mcp-server.mjs:41–89  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

39}
40
41const handle = (msg) => {
42 if (msg.method === "initialize") {
43 send({
44 jsonrpc: "2.0",
45 id: msg.id,
46 result: {
47 // Echo the client's protocol version so we never fail version
48 // negotiation against whatever SDK build is on the other end.
49 protocolVersion: msg.params?.protocolVersion ?? "2025-06-18",
50 capabilities: { tools: {} },
51 serverInfo: { name: "executor-e2e-stdio", version: "1.0.0" },
52 },
53 });
54 return;
55 }
56
57 // Notifications carry no id and expect no response.
58 if (msg.id === undefined || msg.id === null) return;
59
60 if (msg.method === "ping") {
61 send({ jsonrpc: "2.0", id: msg.id, result: {} });
62 return;
63 }
64
65 if (msg.method === "tools/list") {
66 send({ jsonrpc: "2.0", id: msg.id, result: { tools: TOOLS } });
67 return;
68 }
69
70 if (msg.method === "tools/call") {
71 const name = msg.params?.name;
72 const text =
73 name === "whoami"
74 ? (process.env.EXECUTOR_E2E_SECRET ?? "")
75 : String(msg.params?.arguments?.text ?? "");
76 send({
77 jsonrpc: "2.0",
78 id: msg.id,
79 result: { content: [{ type: "text", text }] },
80 });
81 return;
82 }
83
84 send({
85 jsonrpc: "2.0",
86 id: msg.id,
87 error: { code: -32601, message: `Method not found: ${msg.method}` },
88 });
89};
90
91const rl = createInterface({ input: process.stdin });
92rl.on("line", (line) => {

Callers 1

Calls 1

sendFunction · 0.85

Tested by

no test coverage detected