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

Function factory

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

Source from the content-addressed store, hash-verified

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

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