weather

weather

MCP server that provides real-time weather and daily forecast for the nearest city station from China Meteorological Administration based on given latitude and longitude.

Category
Visit Server

README

中国天气 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 配置(自动被识别)

安装

# 本机已用 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 中内置的站点索引扩充为区县级(重新跑构建脚本抓取更多站点即可)。

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured