From mcp-tools
MCP is built on JSON-RPC 2.0 for bidirectional communication between Claude and servers. PROACTIVELY activate for: (1) understanding MCP protocol structure, (2) JSON-RPC message formats, (3) tool vs resource distinction. Triggers: "mcp protocol", "json-rpc", "model context protocol"
How this skill is triggered — by the user, by Claude, or both
Slash command
/mcp-tools:mcp-protocol-fundamentalsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Keywords**: mcp, model context protocol, json-rpc, protocol, specification
Keywords: mcp, model context protocol, json-rpc, protocol, specification
File Patterns: **/mcp_server.py, **/protocol.py
Modes: backend_python, api_development
MCP is built on JSON-RPC 2.0 for bidirectional communication between Claude and servers.
Request Structure:
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "search",
"arguments": {"query": "test"}
},
"id": 1
}
Response Structure:
{
"jsonrpc": "2.0",
"result": {"data": "..."},
"id": 1
}
Error Response:
{
"jsonrpc": "2.0",
"error": {
"code": -32601,
"message": "Method not found"
},
"id": 1
}
Tools (Model-Controlled):
Resources (App-Controlled):
Prompts (Optional):
Server → Client (Server exposes):
tools/list → List available tools
tools/call → Execute a tool
resources/list → List available resources
resources/read → Read resource content
prompts/list → List prompt templates
prompts/get → Get prompt with arguments
Client → Server (Server can request):
sampling/createMessage → Request Claude to generate text
roots/list → Get workspace roots
Claude Desktop MCP Server
| |
|---tools/list-------->|
|<--[tool schemas]-----|
| |
|---tools/call-------->|
| {name, arguments} |
|<--result/error-------|
CRITICAL: Use Pydantic strict mode for all schemas.
from pydantic import BaseModel, ConfigDict
class ToolInput(BaseModel):
model_config = ConfigDict(strict=True)
param: str
# Auto-generates inputSchema:
# {
# "type": "object",
# "properties": {"param": {"type": "string"}},
# "required": ["param"]
# }
MCP supports two transports:
stdio (Standard I/O):
async def main():
async with stdio_server() as (read, write):
await server.run(read, write)
HTTP/SSE (Server-Sent Events):
@app.post("/mcp")
async def handle_mcp(request: JsonRpcRequest):
return await server.handle_request(request)
-32700 → Parse error (invalid JSON)
-32600 → Invalid request
-32601 → Method not found
-32602 → Invalid params
-32603 → Internal error
-32000 to -32099 → Server-defined errors
❌ Manual JSON schema writing (use Pydantic) ❌ Blocking operations in async handlers ❌ Missing error handling ❌ Invalid JSON-RPC 2.0 structure
Official Specification: https://spec.modelcontextprotocol.io/ JSON-RPC 2.0 Spec: https://www.jsonrpc.org/specification Python SDK: https://github.com/modelcontextprotocol/python-sdk
Example Servers:
npx claudepluginhub agentient/vibekit --plugin mcp-toolsRoutes MSP protocol questions to specialized surfaces covering JSON-RPC framing, client/server roles, transports (stdio/HTTP/SSE), and core primitives (tools, resources, prompts, sampling, roots, completion). Includes TypeScript and Python SDK references.
Provides patterns, architecture diagrams, and decision trees for building, testing, and deploying Model Context Protocol (MCP) servers in Python and TypeScript with tools, resources, prompts, and transports like stdio, SSE, streamable HTTP.
Builds, debugs, and extends MCP servers and clients. Scaffolds projects, implements tool handlers and resource providers, configures stdio/HTTP/SSE transport, validates schemas with Zod or Pydantic, and tests protocol compliance.