天气查询服务

一个基于位置信息的天气查询服务,支持通过地点名称或经纬度坐标获取天气数据,并包含地点搜索功能。

  • by hyeri0903
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 hyeri0903/weather-mcp

使用说明

⚒️设置

$ mkdir weather-mcp
$ cd weather-mcp
$ python3 -m venv venv   
$ source venv/bin/activate
$ pip install 'mcp[cli]'  httpx

✅ 设置光标,克劳德桌面设置.json

{
  "mcpServers": {
    "weather-mcp": {
      "command": "${Pyhon-Path}",
      "args": ["${main.py file path"],
      "env": {
        "LOCATION": "Seoul"
      }
    }
  }
}

▶️ 运行开发模式mcp服务器

$ mcp dev main.py

▶️ 运行MCP服务器检查器

$ npx @modelcontextprotocol/inspector dist/index.js

调用函数

# To get weather by location
await get_weather(location="New York")

# To get weather using latitude and longitude
await get_weather(latitude=35.6762, longitude=139.6503)

# Using Env
await get_weather()

# Seach Location tool
await search_location("paris")