使用说明
OpenWeatherMap MCP服务器
一个MCP(模型上下文协议)服务器,提供对OpenWeatherMap API的访问,允许人工智能助手与OpenWeatherMap数据交互。
特性
- 从OpenWeatherMap API列出和检索项目
- 异步HTTP客户端,具有错误处理功能
- 使用Pydantic模型键入响应
安装
使用mpak(推荐)
# Configure your API key
mpak config set @JoeCardoso13/openweathermap api_key=your_api_key_here
# Run the server
mpak run @JoeCardoso13/openweathermap
手动安装
# Clone the repository
git clone https://github.com/NimbleBrainInc/mcp-openweathermap.git
cd mcp-openweathermap
# Install dependencies with uv
uv sync
# Set your API key
export OPENWEATHERMAP_API_KEY=your_api_key_here
# Run the server
uv run python -m mcp_openweathermap.server
配置
获取API密钥
- 首选https://home.openweathermap.org/api_keys
- 创建新的API密钥
- 复制密钥
Claude桌面配置
添加到您的 ~/.claude/settings.json:
{
"mcpServers": {
"openweathermap": {
"command": "mpak",
"args": ["run", "@JoeCardoso13/openweathermap"]
}
}
}
可用工具
| 工具 | 说明 |
|---|---|
list_items |
列出API中具有可选限制的项目 |
get_item |
按ID获取单个项目 |
发展
# Install dev dependencies
uv sync --dev
# Run tests
uv run pytest tests/ -v
# Format code
uv run ruff format src/ tests/
# Lint
uv run ruff check src/ tests/
# Type check
uv run ty check src/
# Run all checks
make check
许可证
麻省理工学院
