Skip to main content
Glama
liuweihongliuxinyu

weather-mcp-server

README.md
# ๐ŸŒค Weather MCP Server

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

[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://www.python.org/)
[![MCP](https://img.shields.io/badge/MCP-1.x-green.svg)](https://modelcontextprotocol.io/)
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

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

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

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

```bash
# 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` ไธญๆทปๅŠ ๏ผš

```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

TDQS

A4/5.0

Scored across 3 tools

Disambiguation5/5

Each tool targets a distinct weather aspect: air quality, current weather, and forecast. There is no overlap in purpose.

Naming Consistency5/5

All tools follow the consistent 'get_' prefix with a noun describing the data type: get_air_quality, get_current_weather, get_forecast.

Tool Count5/5

Three tools is a compact and appropriate number for a weather MCP server, covering the essential weather data endpoints without excess.

Completeness4/5

Covers the core weather needs (current, forecast, air quality). Missing historical data or severe weather alerts, but these are reasonable omissions for a basic weather server.

Maintenance

ActivityStale
ResponsivenessNo issues