天气 MCP 服务器是一个基于模型上下文协议(Model Context Protocol)的服务器,它通过连接国家气象局 API,为用户提供丰富的天气信息。
天气 MCP 服务器能让你轻松获取美国的天气信息。你可以按照以下步骤进行操作,开启天气信息获取之旅。
pip install mcp httpx
若使用 uv,可执行以下命令:uv pip install mcp httpx
直接运行服务器,使用以下命令:
python weather_server.py
与 Claude for Desktop 配合使用,将以下内容添加到你的 Claude for Desktop 配置文件 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"weather_mcp_server": {
"command": "/实际路径/to/uv",
"args": [
"--directory",
"/绝对路径/to/weather_mcp_server",
"运行",
"weather_server.py"
]
}
}
}
⚠️ 重要提示
需将
/实际路径/to/uv替换为你实际的 uv 可执行文件路径(使用which uv找到);将/绝对路径/to/weather_mcp_server替换为该目录的实际绝对路径。