这是一个基于 FastMCP 构建的天气查询服务器,能为用户提供全球城市的天气信息查询服务,满足不同用户对天气数据的需求。
git clone
cd weather-mcp-server
make install
.env 文件并添加以下内容:OPENWEATHER_API_KEY=你的OpenWeatherMap_API密钥
make run
使用 uvx 可以自动从 PyPI 安装包,无需克隆仓库。将以下配置添加到 Claude Desktop 的配置文件 claude_desktop_config.json 中:
{
"mcpServers": {
"weather-mcp-server": {
"command": "uvx",
"args": [
"weather-mcp-server"
],
"env": {
"OPENWEATHER_API_KEY": "你的OpenWeatherMap_API密钥"
}
}
}
}
git clone
cd weather-mcp-server
make install
.env 文件并添加以下内容:OPENWEATHER_API_KEY=你的OpenWeatherMap_API密钥
{
"mcpServers": {
"weather": {
"command": "uv",
"args": [
"--directory",
"path/to/src/weather_mcp_server",
"run",
"weather-mcp-server"
],
"env": {
"OPENWEATHER_API_KEY": "你的OpenWeatherMap_API密钥"
}
}
}
}
配置文件位置:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%/Claude/claude_desktop_config.json重启 Claude Desktop 以加载新的 MCP 服务器。
本项目使用 Makefile 来简化常用命令。
make install # 安装依赖
make format # 格式化代码
make lint # 运行代码检查
make clean # 清理临时文件
make run # 运行服务器
make release version=v0.1.0
服务器提供以下 MCP 工具:
获取指定城市的天气信息。
参数:
city: 城市名称(必填)units: 温度单位(可选,默认为 "metric")
示例请求:
{
"name": "get_weather",
"kwargs": {
"city": "Beijing",
"units": "metric"
}
}
示例响应:
{
"temperature": 20.5,
"humidity": 65,
"description": "晴",
"city": "Beijing"
}
现在您可以通过 Claude 使用自然语言查询天气,例如: