Understanding MCP

MCP Protocol: A revolutionary bridge for connecting large language models
Core content:
1. The definition of the MCP protocol and the core issues it solves
2. How the MCP protocol enables interaction between large models and external data and tools
3. The client and server architecture and interaction methods of the MCP protocol
What is MCP
An open protocol proposed by Anthropic in November 2024 aims to solve the problem of standardized connection between large language models (LLMs) and external data sources and tools.
In my understanding, MCP is equivalent to a human hand. If the big model is to simulate the human brain, our previous interaction with the big model has always been in the form of dialogue and communication.
But with MCP, the brain's instructions can be translated into actual things through the hands.
The actual things here include but are not limited to:
Go to Taobao to place an order Buy flight tickets using Alizhu 3D drawing tools using Blender software Crawl a website using your browser Use Obsidian to query and record a document
Therefore, MCP first needs a client that can handle and accept user needs, then request the big model, and analyze the information returned by the big model to generate instructions, and call the MCP service according to these instructions.
Secondly, MCP needs a server, which is a service interface that encapsulates real behaviors. For example, if I want to use Blender software to draw 3D pictures, I need to build an http server locally, which can call various external interfaces of Blender to perform drawing, and provide this capability to the MCP client.
Generally speaking, the mcp client and mcp server are on the same machine.
The official website https://modelcontextprotocol.io/introduction divides the client into MCP Host and MCP Client. They are actually the same thing. Host refers to the host, such as software like cursor and claude app, and the part that interacts with the MCP server is called MCP Client.
How does the MCP protocol interact?
This picture explains it clearly.
When the MCP Client and MCP Server interact, they will use tools/list
, resources/list
,prompts/list
To obtain the capabilities provided by this MCPServer.
The interface example of tools/list is as follows:
{
"jsonrpc" : "2.0" ,
"id" : 1,
"result" : {
"tools" : [
{
"name" : "search_arxiv" ,
"description" : "Search arXiv articles by keyword" ,
"inputSchema" : {
"type" : "object" ,
"properties" : {
"keyword" : {
"type" : "string" ,
"title" : "Search Query"
},
"max_results" : {
"type" : "integer" ,
"minimum" : 1,
"maximum" : 50
}
},
"required" : [ "keyword" ]
}
},
{
"name" : "create_issue" ,
"description" : "Create GitHub issue" ,
"inputSchema" : {
"type" : "object" ,
"properties" : {
"repo" : { "type" : "string" },
"title" : { "type" : "string" },
"body" : { "type" : "string" }
},
"required" : [ "repo" , "title" ]
}
}
]
}
}
Resources/list API Example
{
"jsonrpc" : "2.0" ,
"id" : 2,
"result" : {
"resources" : [
{
"uri" : "file:///var/log/app.log" ,
"name" : "Application Logs" ,
"mimeType" : "text/plain" ,
"description" : "Real-time server logs"
},
{
"uriTemplate" : "postgres://db/users/{user_id}" ,
"name" : "User Records" ,
"mimeType" : "application/json" ,
"description" : "Query user data by ID"
}
]
}
}
prompts/list API Example
{
"jsonrpc" : "2.0" ,
"id" : 3,
"result" : {
"prompts" : [
{
"name" : "generate_report" ,
"description" : "Generate technical report template" ,
"argumentsSchema" : {
"type" : "object" ,
"properties" : {
"title" : { "type" : "string" },
"sections" : {
"type" : "array" ,
"items" : { "type" : "string" }
}
}
}
},
{
"name" : "explain_code" ,
"description" : "Generate code explanation" ,
"argumentsSchema" : {
"type" : "object" ,
"properties" : {
"code" : { "type" : "string" },
"language" : { "type" : "string" }
},
"required" : [ "code" ]
}
}
]
}
}
As above, I have provided several functions as follows.
Call tools/search_arxiv
Get the paperpass resources/read
Loading local referencesuse prompts/summarize
Generating a Literature Review
How to install an MCP Server locally
The official website https://modelcontextprotocol.io/quickstart/server teaches you how to install a MCP Server locally to check the weather.
This MCP Server provides two tools: get-alertsand
get-forecast
I have tested it myself and the one on the official website is feasible.
Here are a few points that the official website did not mention:
I want to debug this MCP service
mcp command
Graphical debugging tool to test the execution effect of tools/resources/prompts in real time Start command: mcp dev weather.py
(This command must be run in the venv environment)
(weather) ➜ weather git:(master) ✗ mcp dev weather.py
Need to install the following packages:
@modelcontextprotocol/inspector@0.6.0
Ok to proceed? (y) y
Starting MCP inspector...
Proxy server listening on port 3000
? MCP Inspector is up and running at http://localhost:5173 ?
Open port 5173 in the local browser and the page will appear
You can also easily call a tool on it
How to configure the MCP Server in the cursor tool
Our MCP Server is started by the uv command, and its configuration file is as follows:
{
"mcpServers" : {
"weather" : {
"command" : "uv" ,
"args" : [
"--directory" ,
"/Users/jianfengye/Documents/workspace/mcp/weather" ,
"run" ,
"weather.py"
]
}
}
}
After the cursor is configured, enable it to see the tools provided by this service.
You can use @mcp in a cursor to ask for the weather in New York, USA
The point to note here is that the interface provided by the official website can only query the weather in the United States, so don't try to query the weather in China.
What are the existing MCP services?
The open source community has one: https://github.com/punkpeye/awesome-mcp-servers
You can visit https://glama.ai/mcp/servers for query.
Claude also created an MCP Server centralized location: https://cursor.directory