1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| MCP Logger started at 2026-05-08T14:40:13.330040 Command: uv --directory E:/python_learn/MCP/weather/ run weather.py
# 平台向服务器发送信息,表明 MCP 协议版本、平台自身信息等等。 [2026-05-08 14:40:13.341] CLIENT -> SERVER {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{"elicitation":{}},"clientInfo":{"name":"codex-mcp-client","title":"Codex","version":"0.129.0-alpha.15"}}}
# 服务器向平台发送消息,表明 MCP 协议版本,表明自身不支持的能力,发送服务器的信息。 [2026-05-08 14:40:14.179] SERVER -> CLIENT {"jsonrpc":"2.0","id":0,"result":{"protocolVersion":"2025-06-18","capabilities":{"experimental":{},"prompts":{"listChanged":false},"resources":{"subscribe":false,"listChanged":false},"tools":{"listChanged":false}},"serverInfo":{"name":"weather","version":"1.27.0"}}}
# 平台表明收到 [2026-05-08 14:40:14.179] CLIENT -> SERVER {"jsonrpc":"2.0","method":"notifications/initialized"}
# 平台想要进一步获取工具列表 [2026-05-08 14:40:14.179] CLIENT -> SERVER {"jsonrpc":"2.0","id":1,"method":"tools/list","params":{"_meta":{"progressToken":0}}}
[2026-05-08 14:40:14.181] SERVER -> CLIENT { "jsonrpc": "2.0", "id": 1, "result": { "tools": [ { # 工具 1 "name": "get_alerts", "description": "Get weather alerts for a US state.\n\nArgs:\n state: Two-letter US state code (eg CA,NY)\n", # 用于描述 input json 的格式 "inputSchema": { "properties": { "state": { "title": "State", "type": "string" } }, "required": [ "state" ], "title": "get_alertsArguments", "type": "object" }, "outputSchema": { "properties": { "result": { "title": "Result", "type": "string" } }, "required": [ "result" ], "title": "get_alertsOutput", "type": "object" } }, { # 工具 2 "name": "get_forecast", "description": "Get weather forecast for a location.\n\nArgs:\n latitude:Latitude of the location\n longitude:Longitude of the location\n", "inputSchema": { "properties": { "latitude": { "title": "Latitude", "type": "number" }, "longitude": { "title": "Longitude", "type": "number" } }, "required": [ "latitude", "longitude" ], "title": "get_forecastArguments", "type": "object" }, "outputSchema": { "properties": { "result": { "title": "Result", "type": "string" } }, "required": [ "result" ], "title": "get_forecastOutput", "type": "object" } } ] } }
# 询问有无资源可以使用 [2026-05-08 14:40:14.973] CLIENT -> SERVER {"jsonrpc":"2.0","id":2,"method":"resources/list","params":{"_meta":{"progressToken":1}}}
# 询问有无资源模板可以使用 [2026-05-08 14:40:14.974] CLIENT -> SERVER {"jsonrpc":"2.0","id":3,"method":"resources/templates/list","params":{"_meta":{"progressToken":2}}}
[2026-05-08 14:40:14.977] SERVER -> CLIENT {"jsonrpc":"2.0","id":2,"result":{"resources":[]}}
[2026-05-08 14:40:14.978] SERVER -> CLIENT {"jsonrpc":"2.0","id":3,"result":{"resourceTemplates":[]}}
# 平台调用 get_forecast 工具并输入经纬度 [2026-05-08 15:02:34.565] CLIENT -> SERVER {"method":"tools/call","params":{"name":"get_forecast","arguments":{"latitude":40.7128,"longitude":-74.006}},"jsonrpc":"2.0","id":5}
[2026-05-08 15:02:36.344] SERVER -> CLIENT {"jsonrpc":"2.0","id":5,"result":{"content":[{"type":"text","text":"\nOvernight:\nTemperature: 50°F\nWind: 8 mph N\nForecast: A slight chance of rain showers before 5am. Mostly cloudy, with a low around 50. North wind around 8 mph. Chance of precipitation is 20%.\n\n---\n\nFriday:\nTemperature: 60°F\nWind: 8 to 17 mph W\nForecast: Mostly sunny, with a high near 60. West wind 8 to 17 mph.\n\n---\n\nFriday Night:\nTemperature: 51°F\nWind: 2 to 15 mph S\nForecast: A slight chance of rain showers after 2am. Mostly cloudy. Low around 51, with temperatures rising to around 54 overnight. South wind 2 to 15 mph. Chance of precipitation is 20%.\n\n---\n\nSaturday:\nTemperature: 60°F\nWind: 6 to 13 mph S\nForecast: Rain showers likely before 2pm, then showers and thunderstorms. Cloudy. High near 60, with temperatures falling to around 56 in the afternoon. South wind 6 to 13 mph. Chance of precipitation is 90%. New rainfall amounts between a tenth and quarter of an inch possible.\n\n---\n\nSaturday Night:\nTemperature: 53°F\nWind: 5 to 12 mph SW\nForecast: Showers and thunderstorms likely before 2am. Mostly cloudy, with a low around 53. Southwest wind 5 to 12 mph. Chance of precipitation is 70%. New rainfall amounts between a tenth and quarter of an inch possible.\n"}],"structuredContent":{"result":"\nOvernight:\nTemperature: 50°F\nWind: 8 mph N\nForecast: A slight chance of rain showers before 5am. Mostly cloudy, with a low around 50. North wind around 8 mph. Chance of precipitation is 20%.\n\n---\n\nFriday:\nTemperature: 60°F\nWind: 8 to 17 mph W\nForecast: Mostly sunny, with a high near 60. West wind 8 to 17 mph.\n\n---\n\nFriday Night:\nTemperature: 51°F\nWind: 2 to 15 mph S\nForecast: A slight chance of rain showers after 2am. Mostly cloudy. Low around 51, with temperatures rising to around 54 overnight. South wind 2 to 15 mph. Chance of precipitation is 20%.\n\n---\n\nSaturday:\nTemperature: 60°F\nWind: 6 to 13 mph S\nForecast: Rain showers likely before 2pm, then showers and thunderstorms. Cloudy. High near 60, with temperatures falling to around 56 in the afternoon. South wind 6 to 13 mph. Chance of precipitation is 90%. New rainfall amounts between a tenth and quarter of an inch possible.\n\n---\n\nSaturday Night:\nTemperature: 53°F\nWind: 5 to 12 mph SW\nForecast: Showers and thunderstorms likely before 2am. Mostly cloudy, with a low around 53. Southwest wind 5 to 12 mph. Chance of precipitation is 70%. New rainfall amounts between a tenth and quarter of an inch possible.\n"},"isError":false}}
|