Skip to content

Lesson 11 of 12 · 6 min read

MCP from the Wire Up: JSON-RPC, stdio and the Three Primitives

Beneath every MCP SDK is a small protocol: JSON-RPC 2.0 messages (requests with ids, notifications without, results and errors) carried over a transport, which for local servers is a child process whose stdin and stdout carry one message per line. The server exposes three primitives that differ by who controls them: tools the model calls, resources the application attaches, prompts the user picks. A tool call has two kinds of failure that travel differently: a protocol error (the request could not be processed) is a JSON-RPC error, while a tool error (the tool ran and failed) is a normal result flagged isError that the model reads as an observation. Building a minimal server and client by hand makes the framing bugs (a stray print on stdout), the version negotiation (the 2026-07-28 revision replaced the initialize handshake with per-request metadata and server/discover) and the pagination of tool lists concrete, and makes every SDK readable afterwards.

Premium lessonReviewed By the AIAgentInterviews editorial team
Get full Premium access · $25

All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.

6 months · One payment · No auto-renewal

Practise it as an interviewer asks it

Related lessons