What is MCP?
The Model Context Protocol (MCP) is a standardized protocol for communication between AI applications (clients) and context providers (servers). It enables AI models to securely access external data sources, tools, and capabilities through a uniform interface.Protocol Architecture
MCP follows a client-server architecture where:- Servers expose capabilities (tools, resources, prompts)
- Clients consume these capabilities to enhance AI interactions
- Transport handles the communication layer between client and server
Communication Patterns
Request-Response Pattern
MCP uses a request-response pattern for most operations:- Client sends a request message
- Server processes the request
- Server sends a response message
- Client receives and handles the response
Message Types
MCP defines several core message types:Initialization Messages
initialize- Client initiates connection with serverinitialized- Server confirms successful initialization
Capability Discovery
tools/list- Request list of available toolsresources/list- Request list of available resourcesprompts/list- Request list of available promptsresources/templates/list- Request list of resource templates
Execution Messages
tools/call- Execute a specific toolresources/read- Read a specific resourceprompts/get- Get a specific prompt with arguments
Response Format
All responses follow a consistent structure with content arrays:Stdio Transport Mechanism
The most common transport mechanism in MCP is stdio (standard input/output), which enables:- Process-based isolation - Each server runs as a separate process
- Simple deployment - No network configuration required
- Language agnostic - Any language that supports stdio can implement MCP
- Secure by default - Communication stays on the local machine
How Stdio Transport Works
Server Launch
Client spawns the server process with a command (e.g.,
node server.js or python server.py)TypeScript Stdio Transport Example
Fromsource/servers/basic/src/server.ts:298-300:
Python Stdio Transport Example
Fromsource/servers/calculator-py/server.py:32-33:
Server Capabilities
Servers declare their capabilities during initialization:tools- Server can execute operationsresources- Server can provide dataprompts- Server can generate prompt templateslistChanged- Server can notify when lists change
Client Capabilities
Clients also declare capabilities when connecting:Protocol Flow Example
Here’s a complete flow of a client calling a tool:The MCP protocol ensures type safety and validation at both the client and server level, making integrations reliable and predictable.
Next Steps
MCP Servers
Learn how to create and configure MCP servers
MCP Clients
Discover how to build clients that connect to MCP servers
Tools
Understand how to implement tools in your servers
Resources
Explore how to provide data through resources