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

Function factory

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

Source from the content-addressed store, hash-verified

512 };
513
514 const factory = () => {
515 const server = new McpServer({ name: serverName, version: "1.0.0" }, { capabilities: {} });
516 const registered = server.registerTool(
517 currentToolName,
518 {
519 description: "Greets the caller",
520 inputSchema: { name: z.string() },
521 },
522 async ({ name }: { name: string }) => ({
523 content: [{ type: "text" as const, text: `greeting:${name}` }],
524 }),
525 );
526 registrations.add(registered);
527 server.registerTool(
528 "rename_greet",
529 { description: "Renames the greet tool", inputSchema: {} },
530 async (_args, extra) => {
531 renameTool();
532 // `RegisteredTool.update` already emitted list_changed, but with no
533 // relatedRequestId the transport routes it to the standalone GET SSE
534 // stream, which a request-scoped client may never have open. Send it
535 // through the handler's `extra` too: that stamps the request id, so
536 // the notification rides THIS call's response stream and is
537 // guaranteed to reach the caller before the tool result.
538 await extra.sendNotification({ method: "notifications/tools/list_changed" });
539 return { content: [{ type: "text" as const, text: "renamed" }] };
540 },
541 );
542 return server;
543 };
544
545 return { factory, renameTool, initialToolName, renamedToolName };
546};

Callers 4

applyFactoryFunction · 0.85
handleMcpRequestFunction · 0.85
resolveTargetFunction · 0.85

Calls 1

renameToolFunction · 0.85

Tested by

no test coverage detected