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, and prompts.
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: PublicToolName(s,t)= concat(s,"__",t)\text{PublicToolName}(s, t) = \text{ concat}(s, \text{"\_\_"}, t) 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:

  1. 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.
  2. Application-Level Tool Execution Error (result.isError = true): The tool ran, or input validation failed, and returned an actionable diagnostic message inside result.content[0].text. By feeding isError: true back to the LLM as a structured ToolMessage, 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 called search
  • Server 2 (postgres): ALSO exposes a tool called search! Without namespacing, one silently overwrites the other! The Host Orchestrator prevents this using Canonical Prefixing: github__search and postgres__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!