このページでは、第4章で使用するJSON-RPCメッセージをコピー&ペーストしやすい形で提供しています。各コマンドは1行で記述されているため、そのままコピーして使用できます。

準備

まず、電卓サーバーを起動してください:

cd C:\\MCP_Learning\\chapter03  # Windows
cd ~/MCP_Learning/chapter03     # Mac/Linux
uv run python calculator_server.py

Step 1: 初期化(initialize)

以下のメッセージをコピーして、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": {...}}}

Step 2: 準備完了の合図(initialized)

{"jsonrpc": "2.0", "method": "notifications/initialized"}

※このメッセージには応答が返ってきません(通知のため)

Step 3: ツール一覧を見る(tools/list)

{"jsonrpc": "2.0", "method": "tools/list", "id": 1}

期待される応答

利用可能なツール(add, subtract, multiply, divide等)のリストが返ってきます。

Step 4: 計算を実行する(tools/call)

足し算の例(5 + 3)

{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "add", "arguments": {"a": 5, "b": 3}}, "id": 2}

その他の計算例