内容
MCP 服务器
一个 [模型上下文协议](https://modelcontextprotocol.io/) 服务器,使用免费的 [Open-Meteo](https://open-meteo.com/) API 提供天气查询功能 — 无需 API 密钥。
## 功能特点
- **`get_weather` 工具** — 通过城市名称或纬度/经度坐标查询当前天气
- **`weather://current/{lat}/{lon}` 资源** — 访问天气数据作为资源 URI
- **零配置** — 使用 Open-Meteo 的免费 API,无需 API 密钥或账户
## 安装
```bash
git clone <repo-url> weather-mcp
cd weather-mcp
npm install
npm run build
```
## 使用方法
### 运行服务器
```bash
npm run dev # 开发模式(tsx,无构建步骤)
npm start # 生产模式(需要先运行 npm run build)
```
### MCP 客户端配置
添加到您的 MCP 客户端配置中(例如 Claude Code 的 `mcpServers`):
```json
{
"mcpServers": {
"weather": {
"command": "node",
"args": ["/path/to/weather-mcp/dist/index }
}
}
```
或使用开发脚本:
```json
{
"mcpServers": {
"weather": {
"command": "npx",
"args": ["tsx", "/path/to/weather-mcp/src/index.ts"]
}
}
}
```
## 可用### `get_weather`
获取指定位置的当前天气状况。
**参数**(提供城市名称或坐标 参数 | 类型 | 描述 |
|-----------|------|-------------|
location` | 字符串(可选)城市名称,例如 `"北京"`东京"`、`"旧"` |
| `latitude` |(可选) | 纬,例如 `52.52` |
| `longitude` | 数字(可选) | 经度坐标,例如 `41` |
**示例响应:🌤 北京,天气状况
─────────────────────────
🌡 温度: 22.1°C(温度 21.5°C)
💧 湿度: 💨 风速: 公里/小时 西南风°)
☁ 天气状况: 多云
```
## 可用### `weather://current/{lon}`
返回指定坐标天气数据作为 JSON 资源。
## API使用 [Open-Mhttps://open-meteo.com一个免费、开源的天气无需 API 密钥。免费套每天最多 10,000。
## 许可证
ISC