Lesson 33 of 2116
MCP — Connecting External Tools to AI Coding Agents
Model Context Protocol is the USB-C of AI tools. Learn the protocol, wire up a server, and understand why this standard quietly changed the ecosystem.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1The Standard Nobody Expected to Matter
- 2Model Context Protocol
- 3MCP server
- 4MCP client
Concept cluster
Terms to connect while reading
Section 1
The Standard Nobody Expected to Matter
Model Context Protocol (MCP) is an open standard, originally published by Anthropic in late 2024, that lets AI agents talk to external tools using a common JSON-RPC interface. By April 2026 it has hit roughly 100 million monthly downloads with 3,000+ indexed servers and is supported by Claude Code, Codex CLI, Cursor, and Windsurf.
Why this matters
Before MCP, every AI tool invented its own plugin system. If you wrote a GitHub integration for one IDE, it didn't work anywhere else. MCP is the common adapter — one server speaks to every compliant client. The USB-C analogy is apt.
The three primitives
- Tools: functions the agent can call (query_db, create_issue, send_slack_message)
- Resources: read-only data sources the agent can pull from (files, docs, schemas)
- Prompts: reusable prompt templates the server exposes as commands
A minimal MCP server in TypeScript
A real MCP server in ~20 lines. Any compliant client can now call get_forecast with a city string.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({
name: "weather",
version: "1.0.0",
});
server.tool(
"get_forecast",
{
city: z.string().describe("City name"),
},
async ({ city }) => {
const res = await fetch(`https://api.weather.example/${city}`);
const data = await res.json();
return {
content: [{ type: "text", text: JSON.stringify(data) }],
};
},
);
const transport = new StdioServerTransport();
await server.connect(transport);Wiring a server to a client
A claude_desktop_config.json or .claude/mcp.json file wiring two servers. Same file format across Claude Code, Cursor, and Windsurf.
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/path/to/weather-server/index.js"]
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
}
}
}Servers worth knowing in 2026
Compare the options
| Category | Example servers |
|---|---|
| Databases | Postgres, SQLite, MongoDB, Redis |
| Version control | GitHub, GitLab |
| Docs | Sentry, Linear, Notion, Confluence |
| Cloud | AWS, Vercel, Cloudflare, Stripe |
| Browsers | Playwright, Puppeteer, Chrome DevTools |
Security model
- Servers run locally by default — no mystery cloud calls
- The client mediates every tool invocation — user can approve or deny
- Auth flows through the server (API keys, OAuth) — not exposed to the model
- Audit logs of tool calls are the minimum observability you should require
“Protocols are patient. They don't win today; they win in five years.”
Key terms in this lesson
The big idea: MCP turned AI coding tools from siloed islands into a composable ecosystem. If you build, extend, or integrate AI agents in 2026, this is the protocol layer you cannot ignore.
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “MCP — Connecting External Tools to AI Coding Agents”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 75 min
Build It: A Minimal AI Agent Loop From Scratch
An agent is a loop: model decides, tool runs, model reads result, decides again. You'll build one in 100 lines without a framework.
Creators · 50 min
Tool-Use Patterns
The model calls a function you defined, you run it, you return the result. Learn the loop and the common pitfalls.
Creators · 50 min
The Landscape: Copilot vs. Cursor vs. Windsurf vs. Claude Code
The AI coding tool market fragmented fast. Let's map the 2026 landscape honestly: who is for autocomplete, who is for agents, who wins on cost, and what the tradeoffs actually feel like.
