
How MCP Works — The Universal Connector for AI
Your AI assistant can write code, answer questions, and reason about problems. But it can't read your database, check your calendar, or deploy your application — unless someone builds the bridge between the AI and those systems.
MCP (Model Context Protocol) is that bridge. It's an open standard that defines how AI applications connect to external tools, data sources, and workflows. One protocol. Any AI application. Any tool.
What Problem Does MCP Solve?
Before MCP, every AI integration was custom. Want Claude to read files? Build a file integration. Want it to query a database? Build a database integration. Want it to use GitHub? Build a GitHub integration. Every AI application built its own connectors, incompatible with every other application.
MCP standardizes this. An MCP server that exposes GitHub works with Claude Code, Cursor, VS Code Copilot, ChatGPT, and any other MCP-compatible client. Build the integration once, use it everywhere.
Think of it like USB-C for AI. Before USB-C, every device had its own connector. Now one cable works with everything. MCP does the same for AI — one protocol connects any AI to any tool.
The Architecture
MCP follows a client-server model with three participants:
MCP Host — the AI application. Claude Code, Cursor, VS Code with Copilot, ChatGPT. The host manages the user experience and coordinates connections to servers.
MCP Client — a component inside the host that maintains a connection to one MCP server. When Claude Code connects to three MCP servers, it creates three MCP clients — one per server.
MCP Server — a program that exposes capabilities to clients. A filesystem server lets AI read and write files. A database server lets AI run queries. A GitHub server lets AI create pull requests. Servers can run locally (on your machine) or remotely (on the internet).
What Can a Server Expose?
MCP defines three core primitives — three types of things a server can offer:
Tools — executable functions the AI can invoke. search_files, run_query, create_issue, send_email. The AI decides when to call a tool based on the conversation. Tools are the action layer — they DO things.
Resources — data the AI can read for context. File contents, database schemas, API documentation, configuration files. Resources don't do anything — they provide information the AI uses to make better decisions.
Prompts — reusable templates that structure how the AI interacts with the server. System prompts, few-shot examples, domain-specific instructions. Prompts shape the AI's behavior for specific tasks.
Most servers expose tools. Many also expose resources. Prompts are less common but powerful for specialized workflows.
How Does Communication Work?
MCP uses JSON-RPC 2.0 — a simple request-response protocol over JSON. Every message is a JSON object with a method name and parameters.
The protocol has two layers:
Data layer — the JSON-RPC messages themselves. Requests, responses, notifications. Capability negotiation, tool discovery, tool execution, resource reading. This is the "what."
Transport layer — how messages move between client and server. Two options:
- stdio — the client launches the server as a subprocess and communicates through stdin/stdout. Fast, simple, local only. This is how Claude Code talks to local MCP servers.
- Streamable HTTP — the server runs as an HTTP endpoint. Clients POST requests and receive responses (optionally as Server-Sent Events for streaming). Works over the network. This is how remote MCP servers work.
The transport is pluggable — the same JSON-RPC messages work over either transport. A server doesn't need to know whether the client connected via stdio or HTTP.
The Lifecycle
Every MCP connection follows a lifecycle:
-
Initialize — the client sends an
initializerequest with its capabilities. The server responds with its capabilities. This is where they negotiate what features both sides support. -
Discover — the client calls
tools/list,resources/list, andprompts/listto find out what the server offers. -
Use — the AI invokes tools (
tools/call), reads resources (resources/read), and uses prompts as needed during conversations. -
Update — if the server's capabilities change (new tools become available, resources update), it sends notifications to the client.
-
Terminate — the connection closes when the host shuts down or the user disconnects.
The initialization handshake is critical — it's where the client and server agree on protocol version and supported features. If the versions are incompatible, the connection fails cleanly.
Why Does This Matter?
For developers building AI tools: instead of integrating with each AI application separately, build one MCP server that works everywhere.
For AI applications: instead of building custom integrations for every tool, support MCP and get access to the entire ecosystem of MCP servers.
For users: install an MCP server once, use it with any AI application. Switch from Claude Code to Cursor — your MCP servers still work.
The ecosystem is growing fast. As of 2026, MCP is supported by Claude, ChatGPT, VS Code, Cursor, and dozens of other applications. Thousands of MCP servers exist for everything from file systems to databases to cloud services to specialized domain tools.
How Does MCP Compare to APIs?
MCP is not a replacement for REST APIs or GraphQL. It's a layer on top.
An MCP server typically wraps existing APIs. The GitHub MCP server calls the GitHub REST API internally. The PostgreSQL MCP server uses the PostgreSQL wire protocol internally. MCP adds:
- Discovery — the AI can discover what's available without documentation
- Schema — inputs and outputs are formally described so the AI can use them correctly
- Standardization — every MCP server follows the same protocol, so AI applications handle them uniformly
- Security — the protocol includes capability negotiation and the expectation of human-in-the-loop approval for sensitive actions
Next Steps
- How MCP Servers Work — building servers that expose tools and data to AI.
- How MCP Tools Work — the core primitive: executable functions for AI.
- How HTTP Works — the application protocol that Streamable HTTP transport builds on.
Referenced by
- How Context Management Works — Why AI Forgets and How to Fix It
- How MCP Transports Work — stdio, HTTP, and Message Framing
- AI Engineering FAQ
- How MCP Servers Work — Exposing Tools and Data to AI
- How MCP Resources Work — Data Sources for AI Context
- How MCP Clients Work — Connecting AI to Servers
- What is JSON-RPC
- What is MCP
- How AI Agents Work — Tool Use, Reasoning, and the Action Loop