MCP Protocol Overview: Bridging AI Agents with the External World
Introduction
MCP (Model Context Protocol) is an open protocol released by Anthropic that standardizes communication between AI models and external tools/data sources. Through MCP, AI Agents can securely and consistently invoke external system capabilities.
This article provides a systematic introduction to MCP's core principles, interaction mechanisms, and deployment modes.
MCP Protocol Core Principles
Overall Architecture
The MCP protocol defines the communication specification between AI clients (Agents) and MCP Servers, with MCP Servers then interacting with actual business systems:
Working Mechanism
The MCP protocol workflow includes the following key stages:
| Stage | Description |
|---|---|
| Tool Registration | When MCP Server starts, it declares available tools, resources, and prompts to clients |
| Message Format | Uses JSON-RPC 2.0 protocol for communication |
| Invocation Flow | Agent identifies user intent → Selects appropriate MCP tool → Sends invocation request → MCP Server executes business logic → Returns result |
Agent-MCP Interaction Mechanism
Capability Discovery Flow
Agents need to "know" what tools are available and their parameter definitions. This process is completed during the MCP protocol initialization and capability discovery phase:
The entire flow can be divided into three phases:
- Initialization Handshake: Agent and MCP Server establish connection, exchanging capability information and protocol version
- Tool Discovery: Agent retrieves all tool information provided by MCP Server through
tools/listrequest - Actual Invocation: Agent selects appropriate tools based on user intent and initiates invocation requests
tools/list Response Structure
When MCP Server responds to tools/list, the core fields returned are:
| Field | Description |
|---|---|
| name | Unique tool identifier, e.g., create_order |
| description | Tool functionality description, used by LLM to determine when to invoke |
| inputSchema | Parameter definition in JSON Schema format (types, required fields, descriptions, etc.) |
After obtaining this information, the Agent injects it into the LLM's context, enabling the LLM to:
- Understand what tools are available
- Comprehend each tool's purpose
- Know what parameters to pass when invoking
Transport Protocols: stdio vs SSE
MCP Server and client support two transport layer protocols.
stdio (Standard Input/Output)
The stdio mode communicates through process standard input/output:
| Feature | Description |
|---|---|
| Communication Method | Through process stdin and stdout |
| Deployment Location | Must run locally |
| Startup Method | Client directly starts MCP Server process |
| Connection Mode | One-to-one, each client starts an independent process |
| Typical Scenarios | Local development, desktop applications, private deployment |
SSE (Server-Sent Events)
SSE mode is based on HTTP protocol and supports remote deployment:
| Feature | Description |
|---|---|
| Communication Method | HTTP-based server push technology |
| Deployment Location | Can be on remote servers |
| Startup Method | Independently deployed as HTTP service |
| Connection Mode | One-to-many, can serve multiple clients |
| Typical Scenarios | Cloud deployment, SaaS services, public APIs |
Architecture Design Options
Option 1: stdio Mode
Users deploy MCP Server locally, configure business system credentials for communication. The underlying transport is HTTP requests, and authentication depends on the business system's authentication mechanism.
Characteristics:
- Users need to install MCP Server locally
- Business credentials are configured on user's local machine
- MCP Server internally uses HTTP to call business system APIs
- Authentication is handled by the business system
Option 2: SSE Mode
Deploy MCP Server on the server side. A gateway can be added between client and MCP Server for API key authentication.
Characteristics:
- MCP Server is deployed on business system servers (cloud)
- Users don't need local installation, just configure connection URL
- Gateway can be added for unified authentication (API Key)
- Better suited for SaaS and multi-tenant scenarios
Comparison of Two Modes
| Dimension | stdio Mode | SSE Mode |
|---|---|---|
| Deployment Complexity | Users need local installation | Zero installation for users |
| Credential Management | Scattered across user machines | Centralized management |
| Security | Credentials on user side, risk of leakage | Unified control through gateway |
| Updates & Maintenance | Users need to update manually | Server-side updates only |
| Network Requirements | Local process communication, no latency | Network dependent, some latency |
| Observability | Difficult to monitor uniformly | Centralized monitoring and auditing |
| Scalability | Limited by user's local resources | Elastic scaling |
| Suitable Scenarios | Development/testing, private deployment | Production, public services |
Summary
The MCP protocol provides a standardized solution for AI Agent interaction with external systems:
- Protocol Level: Uses JSON-RPC 2.0 to standardize communication format, defining standard flows for initialization, tool discovery, and tool invocation
- Transport Level: Supports both stdio and SSE modes, suitable for local and cloud deployment scenarios respectively
- Architecture Level: MCP Server serves as a middle layer, decoupling Agents from business systems, enabling tool capabilities to be reused across multiple Agents
As AI Agent technology evolves, the MCP protocol is becoming the industry standard for tool invocation, laying the foundation for building a rich AI application ecosystem.