Chunk 3: Tool Registration in Agent Loop

↗ view on GitHub · Gadoes · 2026-05-02 · 4f4fdc5d

- Added isMcpTool(), parseMcpToolName(), mcpToolToOpenAI() helpers in chatTools.ts
- Extended runToolCalls() with optional mcpManager param; detects mcp__ prefix
  and dispatches to McpClientManager.callTool()
- Emits mcp_tool_call_start SSE event per MCP tool call
- Extended runLLMStream() with mcpServerTools, openCircuitSources, mcpManager params
- MCP tools appended to activeTools after existing TOOLS and WORKFLOW_TOOLS
- Open-circuit sources excluded from activeTools; unavailability note appended
  to system prompt (spec Section 2.7)
- Active MCP source names and tools listed in system prompt

Acceptance criteria:
[x] LLM emits MCP tool call by prefixed name (mcp__{server}__{tool})
[x] runToolCalls() dispatches to McpClientManager
[x] Tool result returned in { role: "tool", tool_call_id, content } format
[x] mcp_tool_call_start SSE event emitted with correct fields
[x] Open-circuit source tools absent from activeTools

Tests: 24 pass (10+5+9)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Repository Gadoes/dispumike
Author Gadoes <62180984+Gadoes@users.noreply.github.com>
Authored
Parents f4c51b40
Stats 2 files changed , +409 , -5
Part of MCP Host Plumbing & Agent Loop Integration

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-4f4fdc5d.md from inside the repo you want the change in.

⬇ Download capture-commit-4f4fdc5d.md