← Agentic Harness / MCP
Agentic Harness · MCPReading guide

Model Context Protocol (MCP) & Tool-Calling Internals: JSON-RPC Transports, Constrained Decoding FSMs, and Sandboxed Execution

How the Model Context Protocol (MCP) collapses the $M \times N$ agent-to-tool integration matrix into an $M + N$ JSON-RPC 2.0 standard, how inference engines guarantee $100\%$ syntactically valid tool calls via pushdown/FSM logit masking and deterministic token fast-forwarding, how to scale to $200+$ tools via lazy bi-encoder tool retrieval, and how to defend against indirect prompt injection.

$$\tilde{z}_{t,v} = \begin{cases} z_{t,v} & \text{if } v \in \operatorname{Allowed}(q_t) \\ -\infty & \text{otherwise} \end{cases}, \qquad P_{\text{FSM}}(y_t = v \mid y_{<t}, q_t) = \frac{\exp(\tilde{z}_{t,v})}{\sum_{u \in \operatorname{Allowed}(q_t)} \exp(\tilde{z}_{t,u})}.$$

Chapters in this sub-series

01
Model Context Protocol (MCP) & Tool-Calling Internals: JSON-RPC 2.0 Transports, Constrained Decoding FSMs, Dynamic Tool Discovery & Sandboxing

Dissect the MCP Host–Client–Server architecture (`Tools`, `Resources`, `Prompts`), derive constrained grammar decoding and jump-forward token acceleration, implement a two-stage hybrid BM25 + dense tool router that cuts prompt overhead by $94\%$ on 200-tool registries, and harden tool execution with taint-tracked capability firewalls.