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

Function factory

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

Source from the content-addressed store, hash-verified

487 };
488
489 const factory = () => {
490 const server = new McpServer({ name: serverName, version: "1.0.0" }, { capabilities: {} });
491 const registered = server.registerTool(
492 currentToolName,
493 {
494 description: "Greets the caller",
495 inputSchema: { name: z.string() },
496 },
497 async ({ name }: { name: string }) => ({
498 content: [{ type: "text" as const, text: `greeting:${name}` }],
499 }),
500 );
501 registrations.add(registered);
502 server.registerTool(
503 "rename_greet",
504 { description: "Renames the greet tool", inputSchema: {} },
505 async (_args, extra) => {
506 renameTool();
507 // `RegisteredTool.update` already emitted list_changed, but with no
508 // relatedRequestId the transport routes it to the standalone GET SSE
509 // stream, which a request-scoped client may never have open. Send it
510 // through the handler's `extra` too: that stamps the request id, so
511 // the notification rides THIS call's response stream and is
512 // guaranteed to reach the caller before the tool result.
513 await extra.sendNotification({ method: "notifications/tools/list_changed" });
514 return { content: [{ type: "text" as const, text: "renamed" }] };
515 },
516 );
517 return server;
518 };
519
520 return { factory, renameTool, initialToolName, renamedToolName };
521};

Callers 4

applyFactoryFunction · 0.85
handleMcpRequestFunction · 0.85
resolveTargetFunction · 0.85

Calls 1

renameToolFunction · 0.85

Tested by

no test coverage detected