Advanced·4 min read

MCP (Model Context Protocol)

MCP (Model Context Protocol) is an open protocol developed by Anthropic that standardizes how LLMs connect to external tools, data sources, and servic

Definition

MCP (Model Context Protocol) is an open protocol developed by Anthropic that standardizes how LLMs connect to external tools, data sources, and services. It defines a universal interface so that any LLM host (Claude, any IDE, any application) can connect to any MCP server without custom integration code for each combination.

The Problem MCP Solves

Without MCP, every LLM integration requires custom code:

`

App 1 + Database Tool → custom connector A

App 1 + Web Search Tool → custom connector B

App 2 + Database Tool → custom connector C (again!)

App 2 + Web Search Tool → custom connector D (again!)

`

With MCP:

`

App 1 → [MCP protocol] → MCP Database Server (one server, works everywhere)

App 2 → [MCP protocol] → MCP Web Search Server (one server, works everywhere)

`

Write the server once, it works with any MCP-compatible host.

Architecture

Three Components

MCP Host

  • The application containing the LLM (Claude Desktop, VS Code, custom app)
  • Initiates connections to MCP servers
  • Presents available tools/resources to the LLM
  • MCP Client

  • Lives inside the host application
  • Maintains a persistent connection to one or more MCP servers
  • Translates between the host's LLM and MCP server protocol
  • MCP Server

  • Exposes capabilities (tools, resources, prompts) via the MCP protocol
  • Can be local (filesystem access) or remote (web service)
  • Examples: database server, GitHub server, web search server, file system server
  • `

    [Claude / AI App]

    ↕ (MCP Client)

    [MCP Server A: Filesystem]

    [MCP Server B: GitHub]

    [MCP Server C: Database]

    [MCP Server D: Web Search]

    `

    What MCP Servers Can Expose

    Tools

    Callable functions the LLM can invoke:

    `json

    {

    "name": "read_file",

    "description": "Read the contents of a file",

    "inputSchema": {

    "type": "object",

    "properties": {"path": {"type": "string"}},

    "required": ["path"]

    }

    }

    `

    Resources

    Data that can be read (like file contents, database records):

    `json

    {

    "uri": "file:///home/user/project/README.md",

    "name": "Project README",

    "mimeType": "text/markdown"

    }

    `

    Prompts

    Pre-built prompt templates the LLM can invoke:

    `json

    {

    "name": "git-commit",

    "description": "Generate a commit message for staged changes",

    "arguments": [{"name": "changes", "required": true}]

    }

    `

    Transport Mechanisms

    MCP supports two transport types:

  • stdio: local process communication (for local MCP servers)
  • SSE (Server-Sent Events): HTTP-based (for remote MCP servers)
  • Popular MCP Servers (Official + Community)

    | Server | What It Provides |

    |--------|-----------------|

    | @modelcontextprotocol/server-filesystem | File read/write/list |

    | @modelcontextprotocol/server-github | GitHub repos, issues, PRs |

    | @modelcontextprotocol/server-postgres | PostgreSQL query + schema |

    | @modelcontextprotocol/server-sqlite | SQLite operations |

    | @modelcontextprotocol/server-brave-search | Web search via Brave |

    | @modelcontextprotocol/server-fetch | URL fetching |

    | @modelcontextprotocol/server-memory | Persistent key-value memory |

    | @modelcontextprotocol/server-puppeteer | Browser automation |

    Building an MCP Server (TypeScript Example)

    `typescript

    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: "my-server", version: "1.0.0" });

    server.tool("get_time", "Get current time", {}, async () => ({

    content: [{ type: "text", text: new Date().toISOString() }]

    }));

    const transport = new StdioServerTransport();

    await server.connect(transport);

    `

    MCP vs. Direct Tool Calling

    | Aspect | Direct Function Calling | MCP |

    |--------|------------------------|-----|

    | Integration | Custom per-app | Universal |

    | Server reuse | No | Yes |

    | Discovery | Static | Dynamic (server advertises tools) |

    | Transport | In-process | Local or remote |

    | Ecosystem | Proprietary | Open standard |

    Adoption

  • Claude Desktop: built-in MCP client
  • Claude Code: MCP client + allows adding custom servers
  • VS Code Copilot: MCP support
  • Cursor, Windsurf, Cline: MCP support
  • Community: 1000+ community MCP servers on GitHub
  • Security Considerations

    MCP servers can access sensitive resources (files, databases, APIs). Key considerations:

  • Only enable MCP servers you trust
  • Local servers (stdio) have OS-level access control
  • Remote servers should use OAuth or API key authentication
  • MCP servers can execute arbitrary code — trust level matters
  • Related Concepts

  • Tool Use, Agent, Workflow, API, Integration, Orchestration Frameworks

Go Deeper With Live Instruction

This topic is covered in depth in our llm engineering program (Session 12).