weather-mcp-server

liuweihongliuxinyu/weather-mcp-server
0 starsCommunity

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Provides real-time weather and forecast data via MCP tools, enabling AI agents to query current weather and up to 3-day forecasts for any city.

README.md

๐ŸŒค Weather MCP Server

ไธ€ไธชๆœ€ๅฐๅŒ–ไฝ†ๅฎŒๆ•ด็š„ MCP (Model Context Protocol) ๆœๅŠก็ซฏๅฎž็Žฐ๏ผŒไธบ AI Agent ๆไพ›ๅฎžๆ—ถๅคฉๆฐ”ๆŸฅ่ฏข่ƒฝๅŠ›ใ€‚

![Python](https://www.python.org/) ![MCP](https://modelcontextprotocol.io/) ![License](LICENSE)

ไธบไป€ไนˆๅš่ฟ™ไธช้กน็›ฎ

่ฟ™ๆ˜ฏ ไปŽ้›ถๅญฆ AI Agent ๆžถๆž„ ็š„ๅฎžๆˆ˜้กน็›ฎ #1ใ€‚MCP ๅ่ฎฎๆ˜ฏ AI Agent ไธŽๅค–้ƒจไธ–็•Œไบคไบ’็š„ๆ ‡ๅ‡†ๆŽฅๅฃโ€”โ€”็†่งฃ MCP ๆ˜ฏ็†่งฃๆ•ดไธช Agent ๆžถๆž„็š„็ฌฌไธ€ๆญฅใ€‚ๆœฌ้กน็›ฎ็”จๆœ€ๅฐ็š„ไปฃ็ ้‡๏ผˆ~200 ่กŒ๏ผ‰ๅฑ•็คบ MCP Server ็š„ๅฎŒๆ•ด็”Ÿๅ‘ฝๅ‘จๆœŸใ€‚

ๅฟซ้€Ÿๅผ€ๅง‹

# 1. ๅฎ‰่ฃ…
cd weather-mcp-server
pip install -e .

# 2. ๆต‹่ฏ•
pytest tests/ -v

# 3. ่ฟ่กŒ๏ผˆstdio transport๏ผ‰
weather-mcp

ๆŽฅๅ…ฅ Claude Code

ๅœจ claude_desktop_config.json ๆˆ– .claude/settings.json ไธญๆทปๅŠ ๏ผš

{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "run",
        "--directory", "D:\\AI_Space\\ClaudeCode-DeepSeek\\weather-mcp-server",
        "weather-mcp"
      ]
    }
  }
}

้‡ๅฏ Claude Code ๅŽ๏ผŒไฝ ๅฐฑ่ƒฝ็œ‹ๅˆฐ mcp__weather__get_current_weather ๅ’Œ mcp__weather__get_forecast ไธคไธชๅทฅๅ…ทใ€‚

ๆไพ›็š„ๅทฅๅ…ท

| ๅทฅๅ…ทๅ | ็”จ้€” | ๅ‚ๆ•ฐ | |--------|------|------| | get_current_weather | ๅฎžๆ—ถๅคฉๆฐ”๏ผˆๆธฉๅบฆ/ไฝ“ๆ„Ÿ/้ฃŽ้€Ÿ/ๆนฟๅบฆ/็ดซๅค–็บฟ๏ผ‰ | city (string) | | get_forecast | ๆœชๆฅ N ๅคฉ้ข„ๆŠฅ | city (string), days (int, 1-3) |

ๆžถๆž„

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚           Claude Code (Host)             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   MCP Client (weather)             โ”‚  โ”‚
โ”‚  โ”‚   JSON-RPC over stdio              โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                  โ”‚ stdin/stdout
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Weather MCP Server               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  handle_list_tools()              โ”‚  โ”‚
โ”‚  โ”‚  handle_call_tool()               โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚             โ”‚                            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  fetch_weather() (wttr.in)        โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

้กน็›ฎ็ป“ๆž„

weather-mcp-server/
โ”œโ”€โ”€ pyproject.toml          # ้กน็›ฎ้…็ฝฎๅ’Œไพ่ต–
โ”œโ”€โ”€ README.md               # ๆœฌๆ–‡ไปถ
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ weather_mcp/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ server.py       # MCP Server ๆ ธๅฟƒ๏ผˆ~200่กŒ๏ผ‰
โ””โ”€โ”€ tests/
    โ””โ”€โ”€ test_server.py      # ๅ•ๅ…ƒๆต‹่ฏ• + ้›†ๆˆๆต‹่ฏ•

ๅญฆไผšไบ†ไป€ไนˆ

้€š่ฟ‡่ฟ™ไธช้กน็›ฎไฝ ๅฏไปฅ็†่งฃ๏ผš

  1. MCP ๅ่ฎฎไธ‰ๅฑ‚ๆจกๅž‹: Host โ†’ Client โ†’ Server
  2. JSON-RPC 2.0: MCP ็š„ๅบ•ๅฑ‚ไผ ่พ“ๆ ผๅผ
  3. stdio transport: ่ฟ›็จ‹้—ด้€š่ฟ‡ๆ ‡ๅ‡†่พ“ๅ…ฅ่พ“ๅ‡บ้€šไฟก
  4. Tool ๅฎšไน‰: name + description + input_schema๏ผŒAI ๅฆ‚ไฝ•ๅŒน้…ๅทฅๅ…ท
  5. ไธšๅŠก้€ป่พ‘ไธŽๅ่ฎฎ่งฃ่€ฆ: fetch_weather() ไธ็Ÿฅ้“ MCP ็š„ๅญ˜ๅœจ
  6. ้”™่ฏฏๅค„็†: MCP ๅ่ฎฎ่ฆๆฑ‚่ฟ”ๅ›ž is_error ่€Œ้žๆŠ›ๅผ‚ๅธธ

License

MIT

Related MCP servers

Browse all โ†’