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

Function factory

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

Source from the content-addressed store, hash-verified

639 };
640
641 const factory = () => {
642 const server = new McpServer({ name: serverName, version: "1.0.0" }, { capabilities: {} });
643 const registered = server.registerTool(
644 currentToolName,
645 {
646 description: "Greets the caller",
647 inputSchema: { name: z.string() },
648 },
649 async ({ name }: { name: string }) => ({
650 content: [{ type: "text" as const, text: `greeting:${name}` }],
651 }),
652 );
653 registrations.add(registered);
654 server.registerTool(
655 "rename_greet",
656 { description: "Renames the greet tool", inputSchema: {} },
657 async (_args, extra) => {
658 renameTool();
659 // `RegisteredTool.update` already emitted list_changed, but with no
660 // relatedRequestId the transport routes it to the standalone GET SSE
661 // stream, which a request-scoped client may never have open. Send it
662 // through the handler's `extra` too: that stamps the request id, so
663 // the notification rides THIS call's response stream and is
664 // guaranteed to reach the caller before the tool result.
665 await extra.sendNotification({ method: "notifications/tools/list_changed" });
666 return { content: [{ type: "text" as const, text: "renamed" }] };
667 },
668 );
669 return server;
670 };
671
672 return { factory, renameTool, initialToolName, renamedToolName };
673};

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