← Back to Home
How MCP Works
A technical deep-dive into the Model Context Protocol for developers and the curious.
The Protocol
MCP (Model Context Protocol) is an open standard created by Anthropic that defines how AI assistants communicate with external services. Think of it as a standardized API that any AI can speak.
Under the hood, MCP uses:
- JSON-RPC 2.0 - A lightweight remote procedure call protocol
- HTTP Transport - Requests are sent as POST requests to an MCP endpoint
- Streamable responses - For real-time feedback on long operations
The Flow
AI Agent
Claude, ChatGPT, Cursor...
→
MCP Protocol
JSON-RPC over HTTP
→
WordPress
MCP Server (Plugin)
- Discovery: The AI asks the MCP server "What tools do you have?" via
tools/list - Selection: The AI decides which tool to use based on the user's request
- Execution: The AI calls the tool via
tools/callwith the required parameters - Response: The server executes the action and returns the result
Example Request
Here's what it looks like when an AI asks WordPress to create a post:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "create_post",
"arguments": {
"title": "My New Post",
"content": "Hello world!",
"status": "draft"
}
}
}
And the response:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [{
"type": "text",
"text": "Created post #123: My New Post (draft)"
}]
}
}
Tools vs Resources
MCP defines two main primitives:
🔧 Tools
Actions the AI can take. These do things:
create_postupdate_postdelete_mediarun_query
📄 Resources
Data the AI can read. These provide context:
site://postssite://mediasite://options
Authentication
MCP servers typically use bearer token authentication:
Authorization: Bearer your-secret-token
The token is configured in your WordPress plugin and added to your AI client's MCP configuration.