What Is the Model Context Protocol (MCP)? A Complete Introduction
Learn the fundamentals of MCP — what it is, why it matters, and how it enables AI agents to connect with external tools and data sources through a standardized protocol.
What Is the Model Context Protocol?
The Model Context Protocol (MCP) is an open standard that defines how AI models and autonomous agents communicate with external tools, data sources, and services. Think of it as USB-C for AI — a universal connector that lets any LLM interface with any software ecosystem instantly.
Why MCP Matters
Before MCP, every AI integration was custom-built. Each tool, database, and API required its own bespoke connector written specifically for OpenAI, Anthropic, or LangChain. MCP changes this fragmented ecosystem by providing:
- ▸A standardized interface between AI models and external resources.
- ▸Plug-and-play compatibility across entirely different AI frameworks.
- ▸Security boundaries that explicitly control what data an AI can access.
- ▸Bi-directional communication allowing both querying context and executing actions.
Core Architecture & Communication Flow
MCP is built on a Client-Server-Host pattern using JSON-RPC 2.0.
- ▸MCP Host: The application requesting data or action (e.g., Claude Desktop, VS Code, Cursor).
- ▸MCP Client: The layer within the host that initiates connections, translates prompt requests, and handles security context.
- ▸MCP Server: A lightweight process that acts as an adapter, translating standardized protocol requests into system actions (such as querying a PostgreSQL database or calling Slack's API).
graph TD
subgraph Host Application (e.g., Claude Desktop)
Host[User Interaction / LLM Orchestration] <-->|Internal API| Client[MCP Client]
end
subgraph Secure Sandbox Boundary
Client <-->|JSON-RPC 2.0 over Stdio| ServerA[Filesystem MCP Server]
Client <-->|JSON-RPC 2.0 over SSE| ServerB[PostgreSQL MCP Server]
end
ServerA <-->|Direct OS calls| LocalDir[Local Directory /Projects]
ServerB <-->|SQL Queries| DB[(Production database)]The Three Primitives
MCP defines three core primitives that an MCP Server can expose to the Host:
| Primitive | Description | Analogy | Example |
|---|---|---|---|
| Resources | Read-only data sources exposed by the server. | The Files on a disk. | Database schemas, raw text logs, live application metrics. |
| Tools | Executable functions called by the client that can side-effect the environment. | Executable scripts. | write_file(), merge_pull_request(), run_docker_container(). |
| Prompts | Pre-structured prompt templates provided by the server to guide user intent. | UI Slash Commands. | /explain-codebase, /generate-unit-tests. |
Standard vs. Custom Protocols: Why MCP Wins
Unlike custom REST endpoints or ad-hoc function calling frameworks built inside proprietary platforms:
- ▸Context Negotiation: Hosts automatically query servers to discover their capabilities upon connection (
ListToolsRequest). No configuration files mapping endpoints are required. - ▸Standard Transports: It natively supports simple standard input/output streams (
stdio) for fast local servers, and Server-Sent Events (SSE) for remote web services. - ▸Robust Security Boundaries: Because the client strictly manages the execution context and the server is isolated to specific endpoints, you avoid the extreme risks of allowing an LLM to run raw shell commands on your host system.
Best Practices
- ▸Don't Reinvent the Wheel: Before building a custom MCP server to connect your agent to AWS, Postgres, or GitHub, check the open-source community. Standardized servers already exist for almost every major platform.
- ▸Prefer Stdio Locally: When building your own server for local deployment, always default to the
stdiotransport layer over HTTP/SSE. It eliminates network port conflicts, firewall issues, and CORS problems.
Related Guides
How to Set Up Your First MCP Server in 5 Minutes
A quick-start guide to installing and configuring your very first MCP server with Claude Desktop. Get up and running in minutes.
Getting StartedMCP Server Security Best Practices: Protecting Your Data
Essential security guidelines for running MCP servers. Learn about credential management, access control, and data protection strategies.
Getting StartedConfigure MCP Servers in Codex
Step-by-step config.toml setup for connecting MCP servers to OpenAI Codex CLI.