本文介绍 MCP Server 的开发方法,包括协议基础、传输层选择、Tool 定义。
MCP 是 AI Agent 与外部工具交互的标准化协议。
import json, sys
for line in sys.stdin:
request = json.loads(line)
response = handle_request(request)
print(json.dumps(response), flush=True)
{"name": "get_weather", "inputSchema": {"type": "object", "properties": {"location": {"type": "string"}}}}
Auto-repair applied and deterministic inspection checks passed.
MCP 协议验证通过