Advanced6 min read46 of 52

MCP (Model Context Protocol)

Anthropic's open protocol for connecting LLMs to external tools, data sources, and services.

SPEC: MCP (Model Context Protocol)

Definition

[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)

[Key Insight] 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)

ServerWhat It Provides
@modelcontextprotocol/server-filesystemFile read/write/list
@modelcontextprotocol/server-githubGitHub repos, issues, PRs
@modelcontextprotocol/server-postgresPostgreSQL query + schema
@modelcontextprotocol/server-sqliteSQLite operations
@modelcontextprotocol/server-brave-searchWeb search via Brave
@modelcontextprotocol/server-fetchURL fetching
@modelcontextprotocol/server-memoryPersistent key-value memory
@modelcontextprotocol/server-puppeteerBrowser 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

AspectDirect Function CallingMCP
IntegrationCustom per-appUniversal
Server reuseNoYes
DiscoveryStaticDynamic (server advertises tools)
TransportIn-processLocal or remote
EcosystemProprietaryOpen 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