How MCP Works — A Visual Guide
/ Model Context Protocol
Open Protocol — Anthropic 2024

How MCP connects AI to the world

Model Context Protocol is an open standard that lets AI assistants securely talk to external tools, databases, and services — giving any LLM a universal plug for the real world.

MC
MCP Deep Dive
10 min read  ·  Protocol guide

Every AI assistant faces the same friction: it lives inside a chat window while your data lives everywhere else — in files, databases, APIs, calendars, code repos. Connecting them has meant writing one-off integrations for every tool and every model.

MCP fixes this with a single universal protocol. Think of it like USB-C for AI — one standard connector that works between any host (Claude, GPT, Gemini) and any service (GitHub, Postgres, Slack, your custom API).

Core idea

MCP separates the AI model from its context sources. Servers expose capabilities; hosts discover and call them. Neither side needs to know how the other is built.

Figure 1 — MCP at a glance
AI Host Claude / GPT / Gemini MCP Client built-in JSON-RPC MCP Protocol Capability negotiation Tool discovery Resource access Prompt templates stdio | HTTP + SSE | WebSocket calls GitHub MCP Server Postgres MCP Server Slack MCP Server Your Custom Server
Problem it solves

N×M integration hell

Without MCP, every AI × every tool needs its own adapter. With MCP, it’s one protocol for all combinations.

Security model

User-controlled permissions

The host asks the user before connecting to any server. Servers declare exactly what they expose — nothing hidden.

Transport layer

Multiple transports

Local servers use stdio. Remote servers use HTTP with SSE. Same protocol, different wire.


MCP has three roles. Understanding them is the key to understanding the whole system.

Figure 2 — Three-layer architecture
HOST APPLICATION LLM Generates text, decides which tools to call MCP Client A 1 client per server connection MCP Client B manages lifecycle & capabilities Human in the loop Approves sensitive tool calls before execution JSON-RPC 2.0 JSON-RPC 2.0 MCP Server A e.g. GitHub server Tools: list-repos, create-pr Resources: repo contents MCP Server B e.g. Postgres server Tools: query, insert Resources: table schemas GitHub API Postgres DB
Role 1

Host

The AI application the user runs (Claude Desktop, VS Code, your app). It manages one MCP client per connected server and controls what gets shown to the user.

Role 2

Client

A protocol handler embedded in the host. One client per server. Handles the JSON-RPC 2.0 session: capability negotiation, tool calls, resource reads, and error handling.

Role 3

Server

A lightweight process that wraps a service and exposes it via MCP. Can be local (stdio) or remote (HTTP). Declares its tools, resources, and prompts at connection time.


From a user typing a message to a tool result appearing in the reply, here is every step that happens inside an MCP-powered AI assistant.

MCP Client protocol v2024-11-05 capabilities: {} initialize → ← initialized notifications/initialized → MCP Server Responds with: server name, version capabilities: tools, resources, prompts Session is now active

The first thing that happens when a host connects to a server is a handshake. The client sends its protocol version; the server replies with what it supports. Both sides now know exactly what the other can do. This happens once per session.

MCP Client wants tool list tools/list → ← tools array Tool definitions returned { name: "list-repos", description: "...", inputSchema: {...} } { name: "create-pr", description: "...", inputSchema: {...} } { name: "read-file", description: "...", inputSchema: {...} }

After the handshake, the client asks for a list of available tools, resources, and prompt templates. Each tool comes with a name, description, and JSON schema for its inputs. The host injects these descriptions directly into the LLM’s system prompt — so the model knows what it can call.

User "List my repos" LLM decides to call tool list-repos(owner: "me") MCP Client validates against JSON schema Server tools/call received prompt tool_use block JSON-RPC call

When a user message arrives, the LLM decides whether a tool is needed. If so, it emits a structured tool_use block in its response. The MCP client intercepts this, validates the arguments against the tool’s schema, and forwards the call to the right server via JSON-RPC 2.0.

If tool is sensitive: host pauses and asks user for approval before proceeding MCP Server runs list-repos() own process/thread GitHub API GET /user/repos real HTTP call Result returned to client [{ "name": "my-app", "stars": 42 }, { "name": "dotfiles", "stars": 7 }, ... 14 more repos]

The server executes the tool in its own process — completely isolated from the host. It may call a real API, query a database, read a file, or run any code. The result is serialised and returned to the MCP client as a tool_result block.

tool_result repos: [my-app, dotfiles, ...] LLM (2nd pass) sees tool result in context window synthesises answer Final response "You have 16 repositories. Your most starred is my-app with 42 stars. Would you like to do anything with them?"

The tool result is injected back into the LLM’s context. The model now has real, live data and generates a natural-language response grounded in it. If another tool call is needed (multi-hop), the cycle repeats. The user sees only the final polished answer.


Every MCP server exposes its capabilities through exactly three building blocks. Understanding these tells you everything a server can offer.

Figure 3 — MCP primitives
Tools Model-controlled actions search_database(query) send_email(to, body) create_ticket(title, body) Resources Application-controlled data file:///project/README.md postgres://db/schema slack://channel/general Prompts User-controlled templates summarise_issue(id) code_review(pr_url) explain_error(log_line)
PrimitiveWho controls itPurposeExample
Tools Model Executable actions with side effects Write a file, send a Slack message, query a DB
Resources Application Read-only data exposed as URIs File contents, DB schemas, API responses
Prompts User Reusable prompt templates with arguments Code review template, summarise-issue workflow
Tools vs Resources

Tools can have side effects (write, send, create). Resources are always read-only. If a server needs to modify something, it must be a tool — not a resource. This distinction is enforced by the protocol.


MCP is already powering production workflows across engineering, support, and data teams. Here are the most common patterns.

Developer tooling

Connect Claude to GitHub, Jira, and your CI system. Ask it to open PRs, triage issues, or explain build failures — without leaving your editor.

Data exploration

Natural language queries over Postgres, BigQuery, or Snowflake. The LLM writes SQL, runs it via MCP, and explains the results.

Support automation

Agent reads tickets from Zendesk, looks up account data from Salesforce, drafts a reply, and only escalates when confidence is low.

Business intelligence

Connect to your metrics store. Ask questions in plain English, get charts, and drill down — all driven by MCP tool calls under the hood.

Figure 4 — Multi-server agent workflow
AI Agent "Fix this bug & notify team" GitHub Server read-file, create-pr, comment Postgres Server query, check-logs, explain Slack Server post-message, create-thread 1. reads bug 2. checks logs 3. notifies Opens PR on GitHub.com Queries prod database Posts to #engineering
Getting started

The fastest way to try MCP is Claude Desktop with an open-source server. The MCP registry at modelcontextprotocol.io lists 100+ ready-made servers for GitHub, Postgres, Slack, Notion, Google Drive, and more — most installable in under five minutes.

An MCP server is just a process that speaks JSON-RPC 2.0. The official SDKs for Python and TypeScript handle all the protocol boilerplate — you only write the tool logic.

# Minimal MCP server in Python
from mcp import FastMCP

app = FastMCP("my-server")

@app.tool()
async def search_products(query: str, limit: int = 10) -> list:
    """Search the product catalogue by keyword."""
    results = await db.query(
        "SELECT * FROM products WHERE name ILIKE $1 LIMIT $2",
        f"%{query}%", limit
    )
    return results

@app.resource("catalogue://schema")
async def get_schema() -> str:
    """Expose the DB schema as a resource."""
    return await db.fetch_schema()

# Run via stdio (local) or HTTP (remote)
app.run(transport="stdio")
Step 1

Install the SDK

pip install mcp or npm i @modelcontextprotocol/sdk

Step 2

Define your tools

Decorate functions with @app.tool(). Type hints become the JSON schema automatically.

Step 3

Register with a host

Add your server to Claude Desktop’s config or any MCP-compatible host. Done.

Model Context Protocol — Visual Guide  ·  AI Engineering Series

MCP is an open protocol by Anthropic. Specification at modelcontextprotocol.io

Save to list