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

Function factory

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

Source from the content-addressed store, hash-verified

548 };
549
550 const factory = () => {
551 const server = new McpServer({ name: serverName, version: "1.0.0" }, { capabilities: {} });
552 const registered = server.registerTool(
553 currentToolName,
554 {
555 description: "Greets the caller",
556 inputSchema: { name: z.string() },
557 },
558 async ({ name }: { name: string }) => ({
559 content: [{ type: "text" as const, text: `greeting:${name}` }],
560 }),
561 );
562 registrations.add(registered);
563 server.registerTool(
564 "rename_greet",
565 { description: "Renames the greet tool", inputSchema: {} },
566 async (_args, extra) => {
567 renameTool();
568 // `RegisteredTool.update` already emitted list_changed, but with no
569 // relatedRequestId the transport routes it to the standalone GET SSE
570 // stream, which a request-scoped client may never have open. Send it
571 // through the handler's `extra` too: that stamps the request id, so
572 // the notification rides THIS call's response stream and is
573 // guaranteed to reach the caller before the tool result.
574 await extra.sendNotification({ method: "notifications/tools/list_changed" });
575 return { content: [{ type: "text" as const, text: "renamed" }] };
576 },
577 );
578 return server;
579 };
580
581 return { factory, renameTool, initialToolName, renamedToolName };
582};

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