Skip to main content
Glama
2005Wr
by 2005Wr

中国天气 MCP Server(供 Cline 使用)

通过经纬度查询中国天气的 MCP Server。数据源为**中央气象台(中国气象局)**的公开接口 http://www.nmc.cn/rest/weather

  • 输入:任意经纬度(例如 latitude=39.9087, longitude=116.3975 北京)

  • 输出:该位置最近的市级站点天气实况 + 今日预报(温度、湿度、体感、风向风力、日出日落等)

精度说明:内置一份覆盖全国地级市/直辖市的"城市 → 经纬度 → 气象台站点代码"索引(857 个站点)。 传入经纬度后,先按大圆距离找最近的站点,再调中央气象台接口。距离通常为 15~50 公里,适合日常天气查询,无需精确到区县。

文件说明

文件

作用

cma_weather.py

天气模块:内置站点索引 + 最近站点查找 + 调用中央气象台接口

weather_mcp.py

MCP Server:用 FastMCP 把天气查询封装成工具,供 Cline 调用

requirements.txt

依赖:mcp(Python SDK)

.mcp.json

Cline 的 MCP Server 配置(自动被识别)

Related MCP server: Said MCP

安装

# 本机已用 Python 3.13 测试。安装 mcp 依赖:
py -3.13 -m pip install -r requirements.txt
# 如果上面走代理失败,可禁用代理并加清华镜像:
py -3.13 -m pip install -r requirements.txt --proxy "" -i https://pypi.tuna.tsinghua.edu.cn/simple

若本机没有 py 启动器,改用 python -m pip install -r requirements.txt 即可。

命令行自测(不经过 Cline)

# 直接测试天气模块
py -3.13 cma_weather.py 39.9087 116.3975

# 直接调用 MCP 工具函数
py -3.13 -c "from weather_mcp import get_weather; print(get_weather(39.9087, 116.3975))"

在 Cline 中配置

方式一:项目级 .mcp.json(推荐)

本目录下已提供 .mcp.json。在 VS Code 中打开本项目目录后,打开 Cline 的 MCP 服务器 面板,Cline 会自动发现并加载它,显示 weather 服务。

内容如下(按需改成你机器上的 Python 路径):

{
  "mcpServers": {
    "weather": {
      "type": "stdio",
      "command": "C:\\Users\\34588\\AppData\\Local\\Programs\\Python\\Python313\\python.exe",
      "args": ["d:\\ai_mcp_server\\weather_mcp.py"],
      "env": {}
    }
  }
}

方式二:在 Cline 面板里手动添加

  1. 打开 Cline 侧边栏 → MCP Servers(服务器)标签。

  2. + → 选择 command 类型。

  3. 填写:

    • 名称:weather

    • 命令:C:\Users\34588\AppData\Local\Programs\Python\Python313\python.exe

    • 参数:d:\ai_mcp_server\weather_mcp.py

    • 环境变量:空

  4. 保存后点 连接(Connect),看到 ● weather 已连接即可。

连接失败时看报错:

  • 找不到 Python → 用 where python 查路径后改 .mcp.json 里的 command

  • 缺依赖 → 先执行上面的 pip install。

使用方式

在 Cline 对话中直接提问即可,例如:

查一下北京天安门现在天气怎么样? 深圳下周一会不会下雨?

Cline 的模型会把地名解析为经纬度,然后调用 get_weather 工具:

  • 工具名get_weather

  • 参数latitude(纬度)、longitude(经度)

常见问题

  • 查询失败/超时:中央气象台接口需要能访问 nmc.cn。若在代理/VPN 环境下,请给 MCP 服务配置可用的代理或直连。

  • 返回"天气: -":表示该站点实况字段暂无具体天气描述(源站数据如此),不影响温度等其它字段。

  • 想更精确:如需区县级精确天气,可把 cma_weather.py 中内置的站点索引扩充为区县级(重新跑构建脚本抓取更多站点即可)。

F
license - not found
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    MCP server that provides Korean weather information using grid coordinates and the Korea Meteorological Administration API, allowing users to query current weather conditions and forecasts for specific locations in Korea.
    2
    7
    Apache 2.0
  • F
    license
    C
    quality
    C
    maintenance
    A MCP server that provides real-time weather information for any city through a simple tool that resolves geographic coordinates and fetches current weather data.
    1
    15
  • A
    license
    -
    quality
    D
    maintenance
    An MCP server that provides real-time weather information, 4-day forecasts, and city search functionality for Chinese cities via the AMap API. It enables users to query weather data using city names or administrative codes through natural language interactions.
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • Geospatial MCP server for earthquake, tsunami, volcano, disaster, and FX data queries.

  • 350+ production-ready APIs through one MCP server — weather, geocoding, validation, financial data.

  • OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/2005Wr/mcp_server_weather'

If you have feedback or need assistance with the MCP directory API, please join our Discord server