mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 09:29:38 +02:00
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) <noreply@anthropic.com>
This commit is contained in:
parent
4c356cd24c
commit
6ac5446a76
3 changed files with 21 additions and 3 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
6
ts/entrypoints/mcp-tool.mjs
Normal file
6
ts/entrypoints/mcp-tool.mjs
Normal file
|
|
@ -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);
|
||||
});
|
||||
|
|
@ -36,9 +36,9 @@ export class McpToolService extends FlowProcessor {
|
|||
super(config);
|
||||
|
||||
this.registerSpecification(
|
||||
new ConsumerSpec<ToolRequest>("request", this.onRequest.bind(this)),
|
||||
new ConsumerSpec<ToolRequest>("mcp-tool-request", this.onRequest.bind(this)),
|
||||
);
|
||||
this.registerSpecification(new ProducerSpec<ToolResponse>("response"));
|
||||
this.registerSpecification(new ProducerSpec<ToolResponse>("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<ToolResponse>("response");
|
||||
const responseProducer = flowCtx.flow.producer<ToolResponse>("mcp-tool-response");
|
||||
|
||||
try {
|
||||
const result = await this.invokeTool(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue