Easy AI Tutorial: MCP (Model Context Protocol)
An Easy AI tutorial introducing the Model Context Protocol (MCP) — an open standard protocol (introduced by Anthropic) designed to solve the problem of how AI models interact with external data sources and tools.
Just as USB standardized how devices connect, MCP provides AI models with a unified "plug" — whether connecting to databases, third-party APIs, or local files.
Core Concepts
- Unified standard — a single connection standard, like a USB interface, simplifying AI-to-resource integration
- Broad compatibility — seamless connection to databases, APIs, file systems, and other external resources
- Efficient interaction — optimized protocol design for high-performance communication between models and tools
- Secure and reliable — built-in security mechanisms for data transmission and access
- Database queries — query enterprise databases directly for real-time business data
- Third-party services — connect to weather, stock, and social media APIs
- File operations — read and edit local files; process documents and media
- MCP Host — applications that support MCP, such as Claude Desktop or Cursor
- MCP Client — implements the protocol, handling request management and response processing when communicating with servers
- MCP Server — resource servers that connect to external resources: database connectors, API proxies, file systems, external APIs, and local files
- Direct communication via a local process's standard input/output
- No network required; simple and direct; local use only
- Ideal for local dev environments, CLI tools, local file operations, and system command execution
- Example: a developer uses Cursor IDE locally, launching an MCP server from the command line to process local files
- Connects to remote servers over HTTP with real-time data push
- Cross-network access with persistent connections (requires network)
- Ideal for remote API calls, real-time monitoring, cloud service integration, and live notifications
- Example: an AI assistant calls a remote weather API from the web, getting real-time updates continuously
- *User:* "How much did sales grow this quarter versus last quarter?"
- The MCP Server connects to the sales database and executes SQL queries
- The AI computes the growth rate and generates an analysis report
- *Result:* "This quarter's sales are 5 million, up 15% from last quarter"
- *User:* "Show me today's weather, stocks, and news"
- MCP calls weather, stock, and news APIs in parallel, integrates the data, and generates a personalized unified summary
- Users upload PDF, Word, and Excel files
- The MCP Server parses content and structure; the AI analyzes topics and key data
- Documents are auto-classified and tagged; search indexes enable semantic search
Use Cases
Architecture
The system consists of three main components:
Communication Modes
STDIO Mode
SSE Mode (Server-Sent Events)
Interaction Flow
1. Initialization — the client starts and fetches the tool list: it sends GET /tools/list to the MCP Server, receives tool metadata, and caches it
2. User input — the user makes a natural-language request; the client analyzes it, builds a prompt combined with the tool list
3. LLM processing — the LLM analyzes the prompt, decides whether tools are needed, and returns a tool-call decision
4. Tool execution — the corresponding command template is filled in, executed via the Tool Service, and the local system returns results
5. Result handling — results are formatted, passed to the LLM again for explanation, and a user-friendly answer is presented
Application Examples
Intelligent Data Query Assistant
Real-Time Information Aggregator
Intelligent Document Processor
*Originally published on zhichai.net as part of the Easy AI tutorial series.*