Week 14 • Day 6Week 14
Day 6:MCP Host Orchestrator, Namespacing & Error Recovery
Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz
Day 6: MCP Host Orchestrator, Namespacing & Error Recovery
1. First-Principles Architecture: The MCP Host vs. Client vs. Server
In the official Model Context Protocol specification:
- MCP Host: The user-facing AI application (e.g., Claude Desktop, Cursor, or our Production SRE Copilot) that manages the LLM conversation loop and security permissions.
- MCP Client: A 1-to-1 protocol connector instantiated inside the Host for each connected MCP Server.
- MCP Server: An isolated capability provider exposing
tools,resources, andprompts.
Architecture Flow Diagram
MCP Host (Orchestrator)->C1[MCP Client 1
C2[MCP Client 2
<->|JSON-RPC 2.0| S1[SREMCPServer (k8s)
<->|JSON-RPC 2.0| S2[SREMCPServer (postgres)
2. Tool Namespacing Collision Prevention
What happens when both the github MCP server and the jira MCP server expose a tool named create_issue?
The MCP Host must deterministically namespace tools before presenting them to the LLM:
When the LLM emits a tool call for github__create_issue, the Host splits on __, looks up client github, and dispatches {"method": "tools/call", "params": {"name": "create_issue", ...}}.
3. Structured Self-Correction on MCP Errors
MCP distinguishes between two failure modes:
- Protocol-Level JSON-RPC Error (
error.code < 0): Malformed request, unknown method, or transport crash. The Host catches this and either retries with backoff or fails over. - Application-Level Tool Execution Error (
result.isError = true): The tool ran, or input validation failed, and returned an actionable diagnostic message insideresult.content[0].text. By feedingisError: trueback to the LLM as a structuredToolMessage, the LLM can self-correct its arguments on the next turn.
In Simple English: Avoiding Name Collisions Across Multiple MCP Servers
Suppose you plug 2 MCP servers into one AI Host:
- Server 1 (
github): exposes a tool calledsearch - Server 2 (
postgres): ALSO exposes a tool calledsearch! Without namespacing, one silently overwrites the other! The Host Orchestrator prevents this using Canonical Prefixing:github__searchandpostgres__search(server__tool_name), routes calls to the exact server socket, and translates server timeouts into safe readable feedback so the agent tries an alternative instead of crashing!