Python天气MCP
简单的天气MCP服务器,安装一个调用工具 get_forecast
get_forecast 接受a str (城市)并返回该城市的当前预测
需求
- 一
.env带有OPENWEATHER_API_KEY的文件
- 这可以从以下网站免费获得(https://openweathermap.org/api)
- Python版本>=3.10
安装依赖项
Mise(推荐但首选)
跑 mise install
紫外线(推荐)
跑 uv sync
Pip
跑 pip install .
用作MCP服务器
添加 JSON 将下面的配置更改为使用服务器的应用程序的配置
- 对于VSCode,它处于
/Users/NAME/Library/Application Support/Code/User/settings.json - 对于Claude Desktop,它位于
~/Library/Application Support/Claude/claude_desktop_config.json
系争点
"python-weather-mcp": {
"type": "stdio",
"command": "mise",
"args": [
"--cd",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/Python-Weather-MCP",
"run",
"app"
],
}紫外线的
"python-weather-mcp": {
"type": "stdio",
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/Python-Weather-MCP",
"run",
"weather.py"
],
}Pip
"python-weather-mcp": {
"type": "stdio",
"command": "python",
"args": [
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/Python-Weather-MCP/weather.py"
]
}