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

Function handle

e2e/local/fixtures/codex-app-server.mjs:44–102  ·  view source on GitHub ↗
(msg)

Source from the content-addressed store, hash-verified

42}
43
44const handle = (msg) => {
45 // Notifications (`initialized`) carry no id and expect no response.
46 if (msg.id === undefined || msg.id === null) return;
47
48 if (msg.method === "initialize") {
49 send({ jsonrpc: "2.0", id: msg.id, result: { userAgent: "codex-e2e-fixture/0.0.0" } });
50 return;
51 }
52
53 if (msg.method === "thread/start") {
54 send({ jsonrpc: "2.0", id: msg.id, result: { thread: { id: THREAD_ID } } });
55 return;
56 }
57
58 if (msg.method === "mcpServerStatus/list") {
59 send({
60 jsonrpc: "2.0",
61 id: msg.id,
62 result: {
63 data: [
64 {
65 name: "messages",
66 runtimeStatus: "connected",
67 pluginId: "messages",
68 serverInfo: null,
69 tools: TOOLS,
70 resources: [],
71 resourceTemplates: [],
72 authStatus: "unsupported",
73 },
74 ],
75 nextCursor: null,
76 },
77 });
78 return;
79 }
80
81 if (msg.method === "mcpServer/tool/call") {
82 const { server, tool } = msg.params ?? {};
83 if (server !== "messages" || TOOLS[tool] === undefined) {
84 send({
85 jsonrpc: "2.0",
86 id: msg.id,
87 error: { code: -32602, message: `unknown server or tool: ${server}/${tool}` },
88 });
89 return;
90 }
91 const text =
92 tool === "echo_tool" ? String(msg.params?.arguments?.text ?? "") : "codex-home-present";
93 send({ jsonrpc: "2.0", id: msg.id, result: { content: [{ type: "text", text }] } });
94 return;
95 }
96
97 send({
98 jsonrpc: "2.0",
99 id: msg.id,
100 error: { code: -32601, message: `Method not found: ${msg.method}` },
101 });

Callers 1

Calls 1

sendFunction · 0.70

Tested by

no test coverage detected