AI & Machine LearningIntermediate

MCP (Model Context Protocol)

Open protocol, introduced by Anthropic in 2024, that standardizes how AI applications connect to external tools, data, and services.

Pronunciation

/ɛm siː piː/
"em-see-pee"
Listen on:Forvo

What is it

MCP (Model Context Protocol) is an open protocol that defines how AI applications (assistants like Claude or ChatGPT, IDEs like Cursor or VS Code, custom agents) connect to external tools, data sources, and services.

Anthropic introduced it in November 2024 and, in December 2025, donated it to the Agentic AI Foundation (AAIF), a directed fund under the Linux Foundation, so the protocol evolves under vendor-neutral governance.

The official documentation compares it to a USB-C port for AI applications: a standard connector so any compatible application can use any MCP server without custom integrations.

Common pronunciation mistakes

  • ❌ “mick-pee” (it’s an acronym, not a word)

Why MCP exists

The problem before MCP

┌─────────────────────────────────────────────────────────┐
│                   NO STANDARD (Before)                   │
├─────────────────────────────────────────────────────────┤
│                                                          │
│   AI App A ───→ Custom integration A ──→ Your App       │
│                                                          │
│   AI App B ───→ Custom integration B ──→ Your App       │
│                (different format)                        │
│                                                          │
│   AI App C ───→ Custom integration C ──→ Your App       │
│                (yet another format)                      │
│                                                          │
│   = 3 different integrations for the same thing         │
│                                                          │
└─────────────────────────────────────────────────────────┘

The solution with MCP

┌─────────────────────────────────────────────────────────┐
│                   WITH MCP (Now)                         │
├─────────────────────────────────────────────────────────┤
│                                                          │
│   AI App A ─┐                                            │
│             │                                            │
│   AI App B ─┼────→ MCP Server ────→ Your App            │
│             │      (one format)                          │
│   AI App C ─┘                                            │
│                                                          │
│   = 1 integration works for all compatible apps         │
│                                                          │
└─────────────────────────────────────────────────────────┘

MCP Architecture

MCP defines three participants:

Component Role Example
Host The AI application the user interacts with Claude Desktop, Cursor, VS Code
Client Component inside the host that keeps a 1:1 connection with one server One per connected server
Server Program that exposes tools, resources, and prompts Your backend, a GitHub or filesystem server

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..."    │                  │
     │ ←───────────────│                  │

Messages are JSON-RPC 2.0, sent over stdio (local servers) or HTTP (remote servers).

Practical example: Basic MCP Server

Using the official TypeScript SDK (v2, @modelcontextprotocol/server package):

// server.ts - A minimal MCP server
import { McpServer } from "@modelcontextprotocol/server";
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
import * as z from "zod/v4";

const server = new McpServer({ name: "my-tasks-server", version: "1.0.0" });

// Register a tool: the SDK advertises it in tools/list
// and validates arguments against the schema before calling the handler
server.registerTool(
  "get_tasks",
  {
    description: "Gets the list of tasks",
    inputSchema: z.object({
      status: z.enum(["pending", "completed", "all"]),
    }),
  },
  async ({ status }) => {
    const tasks = await fetchTasksFromDB(status);
    return { content: [{ type: "text", text: JSON.stringify(tasks) }] };
  }
);

// Start server over stdio
const transport = new StdioServerTransport();
await server.connect(transport);

MCP Capabilities

An MCP server can expose 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 }
  ]
}
Server Function Maintainer
filesystem Local file access with access controls MCP project (reference server)
git Read, search, and manipulate Git repositories MCP project (reference server)
fetch Fetch web content and convert it for the LLM MCP project (reference server)
GitHub MCP Server GitHub issues, PRs, and repos GitHub (official server)

Several older reference servers (PostgreSQL, Slack, Google Drive, among others) were archived in the servers-archived repository; today it’s better to look for each vendor’s official server.

Configuration in Claude Desktop

// ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
{
  "mcpServers": {
    "my-server": {
      "command": "node",
      "args": ["/path/to/server.js"],
      "env": {
        "API_KEY": "your-api-key"
      }
    }
  }
}

Security in MCP

Security principles

  1. Least privilege: Expose only what’s necessary
  2. Validation: Verify all inputs
  3. Authentication: Use tokens for access (the specification defines OAuth-based authorization for HTTP servers)
  4. Auditing: Log all operations
  5. Distrust external content: tool output can carry prompt injection

Validation example

server.registerTool(
  "delete_task",
  {
    description: "Deletes a task owned by the current user",
    // The schema rejects invalid arguments before execution
    inputSchema: z.object({ id: z.string().uuid() }),
  },
  async ({ id }) => {
    // Check permissions on the server; never trust the model
    if (!(await userCanDelete(id))) {
      return { isError: true, content: [{ type: "text", text: "Operation not allowed" }] };
    }
    await deleteTask(id);
    return { content: [{ type: "text", text: `Task ${id} deleted` }] };
  }
);
  • Agentic AI - AI that acts autonomously using tools
  • API - Application Programming Interface
  • Webhook - HTTP callback for events

Official Resources: