MCP (Model Context Protocol)
Open protocol created by Anthropic that standardizes how AI agents connect to external applications and services.
Pronunciation
What is it
MCP (Model Context Protocol) is an open protocol developed by Anthropic that defines how AI models (like Claude, ChatGPT, Gemini) connect to external applications and services.
Think of MCP as a “USB for AI”: a standard that allows any AI to connect to any service consistently.
Pronunciation
IPA: /ɛm siː piː/
Sounds like: “em-see-pee” - each letter pronounced separately
Common mistakes:
- ❌ “m-c-p” (rushing through without clear separation)
Why MCP exists
The problem before MCP
┌─────────────────────────────────────────────────────────┐
│ NO STANDARD (Before) │
├─────────────────────────────────────────────────────────┤
│ │
│ Claude ────→ Anthropic Plugin ────→ Your App │
│ │
│ ChatGPT ───→ OpenAI Plugin ───────→ Your App │
│ (different format) │
│ │
│ Gemini ────→ Google Extension ────→ Your App │
│ (yet another format) │
│ │
│ = 3 different integrations for the same thing │
│ │
└─────────────────────────────────────────────────────────┘
The solution with MCP
┌─────────────────────────────────────────────────────────┐
│ WITH MCP (Now) │
├─────────────────────────────────────────────────────────┤
│ │
│ Claude ─┐ │
│ │ │
│ ChatGPT ─┼────→ MCP Server ────→ Your App │
│ │ (one format) │
│ Gemini ─┘ │
│ │
│ = 1 integration works for all AIs │
│ │
└─────────────────────────────────────────────────────────┘
MCP Architecture
MCP defines three main components:
| Component | Role | Example |
|---|---|---|
| Host | The AI application | Claude Desktop, Cursor |
| Client | Maintains connection with servers | MCP Library |
| Server | Exposes resources and tools | Your backend |
Communication flow
┌──────────┐ ┌──────────┐ ┌──────────┐
│ Host │ │ Client │ │ Server │
│ (Claude) │ ←──→ │ (MCP) │ ←──→ │(Your API)│
└──────────┘ └──────────┘ └──────────┘
│ │ │
│ "List my │ │
│ tasks" │ │
│ ───────────────→│ │
│ │ tools/list │
│ │ ────────────────→│
│ │ │
│ │ [getTasks, │
│ │ createTask] │
│ │ ←────────────────│
│ │ │
│ │ tools/call │
│ │ getTasks() │
│ │ ────────────────→│
│ │ │
│ │ [{id:1, ...}] │
│ │ ←────────────────│
│ "You have 5 │ │
│ tasks..." │ │
│ ←───────────────│ │
Practical example: Basic MCP Server
// server.ts - A minimal MCP server
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const server = new Server({
name: "my-tasks-server",
version: "1.0.0",
});
// Define available tools
server.setRequestHandler("tools/list", async () => ({
tools: [
{
name: "get_tasks",
description: "Gets the list of pending tasks",
inputSchema: {
type: "object",
properties: {
status: {
type: "string",
enum: ["pending", "completed", "all"]
}
}
}
}
]
}));
// Implement the tool
server.setRequestHandler("tools/call", async (request) => {
if (request.params.name === "get_tasks") {
const tasks = await fetchTasksFromDB(request.params.arguments.status);
return { content: [{ type: "text", text: JSON.stringify(tasks) }] };
}
});
// Start server
const transport = new StdioServerTransport();
await server.connect(transport);
MCP Capabilities
MCP allows exposing three types of capabilities:
1. Tools
Functions that AI can execute:
{
"name": "send_email",
"description": "Sends an email to a recipient",
"inputSchema": {
"type": "object",
"properties": {
"to": { "type": "string" },
"subject": { "type": "string" },
"body": { "type": "string" }
},
"required": ["to", "subject", "body"]
}
}
2. Resources
Data that AI can read:
{
"uri": "file:///config/settings.json",
"name": "System configuration",
"mimeType": "application/json"
}
3. Prompts (Templates)
Reusable instructions:
{
"name": "code_review",
"description": "Template for code review",
"arguments": [
{ "name": "file", "required": true }
]
}
Popular MCP Servers
| Server | Function | Maintainer |
|---|---|---|
| filesystem | Local file access | Anthropic |
| github | Repo operations | Anthropic |
| postgres | PostgreSQL queries | Anthropic |
| slack | Messages and channels | Community |
| google-drive | Drive files | Community |
Configuration in Claude Desktop
// ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"my-server": {
"command": "node",
"args": ["/path/to/server.js"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Security in MCP
Security principles
- Least privilege: Expose only what’s necessary
- Validation: Verify all inputs
- Authentication: Use tokens for access
- Auditing: Log all operations
Validation example
server.setRequestHandler("tools/call", async (request) => {
// Validate that the tool exists
if (!allowedTools.includes(request.params.name)) {
throw new Error("Tool not allowed");
}
// Validate parameters
const validated = schema.parse(request.params.arguments);
// Execute with limited permissions
return executeWithSandbox(request.params.name, validated);
});
Related terms
- [[Agentic AI]] - AI that acts autonomously using tools
- [[API]] - Application Programming Interface
- [[Webhook]] - HTTP callback for events
Official Resources: