xiaohongshu
xiaohongshu
mcp-protocol-fundamentals
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"
Full skill instructions
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:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience