From 6ac5446a76a5449b92b57f68ca9f342a63d0ff40 Mon Sep 17 00:00:00 2001 From: elpresidank Date: Fri, 1 May 2026 22:16:37 -0500 Subject: [PATCH] feat(mcp-tool): wire McpToolService into deploy stack Three pieces, all required for an end-to-end MCP tool call: * McpToolService used generic spec names "request"/"response" instead of "mcp-tool-request"/"mcp-tool-response", so RequestResponseSpec's flow-config topic lookup never matched and consumers bound to literal subjects nobody else publishes to. * Add entrypoints/mcp-tool.mjs (mirrors agent/librarian entrypoints) so the service can be launched in the prebuilt trustgraph-ts image. * Add a `mcp-tool` service block to deploy/docker-compose.yml. With these three fixes plus a `mcp-tool-request`/`mcp-tool-response` entry in each flow's topics map, the agent ReAct loop can now invoke remote MCP tools (verified end-to-end against Brave Search and FireCrawl). Co-Authored-By: Claude Opus 4.7 (1M context) --- ts/deploy/docker-compose.yml | 12 ++++++++++++ ts/entrypoints/mcp-tool.mjs | 6 ++++++ ts/packages/flow/src/agent/mcp-tool/service.ts | 6 +++--- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 ts/entrypoints/mcp-tool.mjs diff --git a/ts/deploy/docker-compose.yml b/ts/deploy/docker-compose.yml index 8d6839e0..9b9f9c6d 100644 --- a/ts/deploy/docker-compose.yml +++ b/ts/deploy/docker-compose.yml @@ -298,6 +298,18 @@ services: - trustgraph restart: unless-stopped + mcp-tool: + image: trustgraph-ts:local + command: ["node", "entrypoints/mcp-tool.mjs"] + environment: + - NATS_URL=nats://nats:4222 + depends_on: + nats: + condition: service_healthy + networks: + - trustgraph + restart: unless-stopped + librarian: image: trustgraph-ts:local command: ["node", "entrypoints/librarian.mjs"] diff --git a/ts/entrypoints/mcp-tool.mjs b/ts/entrypoints/mcp-tool.mjs new file mode 100644 index 00000000..3418eb71 --- /dev/null +++ b/ts/entrypoints/mcp-tool.mjs @@ -0,0 +1,6 @@ +import("../packages/flow/dist/agent/mcp-tool/service.js") + .then((m) => m.McpToolService.launch("mcp-tool")) + .catch((err) => { + console.error(err); + process.exit(1); + }); diff --git a/ts/packages/flow/src/agent/mcp-tool/service.ts b/ts/packages/flow/src/agent/mcp-tool/service.ts index 1d70d64e..6fdc2be3 100644 --- a/ts/packages/flow/src/agent/mcp-tool/service.ts +++ b/ts/packages/flow/src/agent/mcp-tool/service.ts @@ -36,9 +36,9 @@ export class McpToolService extends FlowProcessor { super(config); this.registerSpecification( - new ConsumerSpec("request", this.onRequest.bind(this)), + new ConsumerSpec("mcp-tool-request", this.onRequest.bind(this)), ); - this.registerSpecification(new ProducerSpec("response")); + this.registerSpecification(new ProducerSpec("mcp-tool-response")); this.registerConfigHandler(this.onMcpConfig.bind(this)); } @@ -79,7 +79,7 @@ export class McpToolService extends FlowProcessor { const requestId = properties.id; if (!requestId) return; - const responseProducer = flowCtx.flow.producer("response"); + const responseProducer = flowCtx.flow.producer("mcp-tool-response"); try { const result = await this.invokeTool(