このページでは、第4章で使用するJSON-RPCメッセージをコピー&ペーストしやすい形で提供しています。各コマンドは1行で記述されているため、そのままコピーして使用できます。
まず、電卓サーバーを起動してください:
cd C:\\MCP_Learning\\chapter03 # Windows
cd ~/MCP_Learning/chapter03 # Mac/Linux
uv run python calculator_server.py
以下のメッセージをコピーして、Enterキーを押してください:
{"jsonrpc": "2.0", "method": "initialize", "params": {"protocolVersion": "0.1.0", "capabilities": {}, "clientInfo": {"name": "test", "version": "0.1.0"}}, "id": 0}
{"jsonrpc": "2.0", "id": 0, "result": {"protocolVersion": "2025-06-18", "capabilities": {...}}}
{"jsonrpc": "2.0", "method": "notifications/initialized"}
※このメッセージには応答が返ってきません(通知のため)
{"jsonrpc": "2.0", "method": "tools/list", "id": 1}
利用可能なツール(add, subtract, multiply, divide等)のリストが返ってきます。
{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "add", "arguments": {"a": 5, "b": 3}}, "id": 2}