Skip to content

MCP Protocol Explained

Cheatsheet of the Model Context Protocol: the roles (host, client, server), the three primitives (resources, tools, prompts), transports, and lifecycle.

MCP is USB for AI context: one open protocol so any client (IDE, chat app, agent) can talk to any context source (databases, APIs, files) without bespoke integrations per pair.

Reference table · 14 entries
14 of 14 rows
Roles
HostThe AI application the user runs — owns the model and the permissions.Claude Desktop, an IDE, your agent
ClientThe connector inside the host; one client per server, 1:1.host spawns a client per MCP server
ServerThe program exposing capabilities over the protocol.a Postgres MCP server
Primitives
ResourcesRead-only context the model can attach — files, rows, documents.resources/list → resources/read
ToolsExecutable functions the model may call, with user approval.tools/call { name: 'query', args }
PromptsReusable prompt templates the server ships; user-invoked.prompts/get { name: 'code-review' }
SamplingServer asks the host's model to complete text — the reverse direction.sampling/createMessage
Transports
stdioLocal servers: JSON-RPC over the process's stdin/stdout.command: npx mcp-server-pg
Streamable HTTPRemote servers: HTTP POST + optional SSE stream.https://mcp.example.com/mcp
JSON-RPC 2.0The message envelope everywhere — requests, responses, notifications.{"jsonrpc":"2.0","method":"tools/list"}
Lifecycle
initializeClient and server exchange capabilities and protocol version.initialize → initialized
DiscoveryList what exists: tools/list, resources/list, prompts/list.tools/list
OperationNormal traffic — calls, reads, subscriptions.resources/subscribe
ShutdownClose the transport; no special message required.process exit / connection close