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

Function factory

packages/plugins/mcp/src/testing/server.ts:603–632  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

601 };
602
603 const factory = () => {
604 const server = new McpServer({ name: serverName, version: "1.0.0" }, { capabilities: {} });
605 const registered = server.registerTool(
606 currentToolName,
607 {
608 description: "Greets the caller",
609 inputSchema: { name: z.string() },
610 },
611 async ({ name }: { name: string }) => ({
612 content: [{ type: "text" as const, text: `greeting:${name}` }],
613 }),
614 );
615 registrations.add(registered);
616 server.registerTool(
617 "rename_greet",
618 { description: "Renames the greet tool", inputSchema: {} },
619 async (_args, extra) => {
620 renameTool();
621 // `RegisteredTool.update` already emitted list_changed, but with no
622 // relatedRequestId the transport routes it to the standalone GET SSE
623 // stream, which a request-scoped client may never have open. Send it
624 // through the handler's `extra` too: that stamps the request id, so
625 // the notification rides THIS call's response stream and is
626 // guaranteed to reach the caller before the tool result.
627 await extra.sendNotification({ method: "notifications/tools/list_changed" });
628 return { content: [{ type: "text" as const, text: "renamed" }] };
629 },
630 );
631 return server;
632 };
633
634 return { factory, renameTool, initialToolName, renamedToolName };
635};

Callers 5

evaluateComponentFunction · 0.85
applyFactoryFunction · 0.85
handleMcpRequestFunction · 0.85
resolveTargetFunction · 0.85

Calls 1

renameToolFunction · 0.85

Tested by

no test coverage detected