Anthropic’s Model Context Protocol (MCP) is a significant development aimed at standardizing how AI models, particularly large language models (LLMs), interact with external data sources and tools. Intuitively, MCP provide a standardized function calling protocol across different LLM providers.
Architecture
MCP follows a client-server architecture where:
- Hosts are LLM applications (like Claude Desktop or IDEs) that initiate connections
- Clients maintain 1:1 connections with servers, inside the host application
- Servers provide context, tool (function calling in LLMs), and Prompts (Terminology/Prompts) to clients
flowchart TD
%% Define the Host and its components
subgraph Host
MCP_Client1[MCP Client]
MCP_Client2[MCP Client]
end
%% Define the Server Processes and their components
subgraph Server_Process1[Server Process]
MCP_Server1[MCP Server]
end
subgraph Server_Process2[Server Process]
MCP_Server2[MCP Server]
end
%% Define the connections via Transport Layer
MCP_Client1 -->|Transport Layer| MCP_Server1
MCP_Client2 -->|Transport Layer| MCP_Server2
Transports
All transports use JSON-RPC 2.0 to exchange messages.
- Message formats
|
|
- Transport types:
- The
STDIOtransport method launches an MCP server as a subprocess and communicates with it through standard input/output streams for local execuation. SSEtransport enables server-to-client streaming with [[HTTP]] POST requests for client-to-server communication.- Custom: Any transport implementation just needs to conform to the Transport interface.
- The
MCP and Prompt
Use [[cloudflare#AI gateway]] to log the [[HTTP]] messages between VSCode-Cline client and LLM provider DeepSeek V3:
- The sent system Prompts (Terminology/Prompts) provide the information of MCP servers and tool (function calling in LLMs)’s configurations.
use_mcp_toolaccess_mcp_resourceAvailable Tools: each MCP server provides a list of tools
- The first received response will be the LLM’s choice of MCP server and tools’ configuration.
- The client (vscode-cline) then call the specific tool and wrap the result with context back to the LLM.
- For those LLM models that does not provide function call API but support MCP, MCP can still serve as an acceptable middle layer to use the external resources.
|
|
The LLM model (DeepSeek) will then return an assistant message as follows to indicate determined MCP server and tools. The application could further construct the MCP request message:
|
|
Given the above returned assistant message, the application will build the MCP request to MCP server, run the corresponding tools, and construct the secound round messages sent to LLM based on MCP responses. The workflow is similar to the function call (function calling in LLMs).
examples
WindSurf MCP setup
- User Prompt: “my github user name is monchewharry, what repo i have on github?”
|
|
npx command) to find the info on github.
The nodejs program’s actual run:
|
|
Similar setup could be done for Curosr and VSCode (through extension Cline).
Common MCP servers
- https://github.com/modelcontextprotocol/servers
- smithery.ai is a collection of powerful MCP servers.