Back to MCP directory
publicPublicdnsLocal runtime

mcp-us-city-weather

一个基于MCP框架的天气信息服务项目,通过国家气象局API提供城市天气预报功能

article

README

🚀 天气 MCP 服务器

本项目是一个基于 MCP(模型完成协议)框架搭建的天气信息服务。借助国家气象局 (NWS) API,该服务能为任意城市提供精准的天气预报,满足用户对天气信息的需求。

🚀 快速开始

此存储库包含的天气信息服务,通过 MCP 框架与国家气象局 API 结合,可轻松实现城市天气信息的获取。

✨ 主要特性

  • 地理编码:可将城市名称转换为对应的纬度/经度坐标。
  • 数据获取:能从国家气象局 API 提取天气数据。
  • 详细预报:提供包括温度、天气状况和风信息等在内的详细天气预报。
  • 模块化设计:各个步骤都配备独立工具,便于维护和扩展。

📦 安装指南

我们推荐使用 uv 来管理您的 Python 项目,安装命令如下:

uv add "mcp[cli]"

若您不想使用 uv,也可直接使用 pip 进行安装:

pip install mcp

💻 使用示例

基础用法

在本地测试 MCP 服务器

使用以下命令在本地对 MCP 服务器进行测试:

mcp dev weather.py

配置与 Claude Desktop 使用

要在 Claude Desktop 中使用此天气服务器,需将以下配置添加到您的 Claude Desktop 配置文件中:

{
  "mcpServers": {
    "my_python_server": {
      "command": "/Users/<user_name>/.local/bin/uv",
      "args": [
        "--directory",
        "/Users/<user_name>/<git_repository_path>",
        "run",
        "weather.py"
      ]
    }
  }
}

请将路径替换为您的实际路径:</Users/user_name/Your_directory>

高级用法

配置完成后,您可以向 Claude 提出如下问题:

  • “旧金山的天气如何?”
  • “纽约市的天气怎么样?”
  • “获取芝加哥的天气预报”

Claude 将利用 MCP 服务器获取并展示相应的天气信息。

📄 许可证

本项目依据 Creative Commons Attribution - NonCommercial 4.0 国际许可证(CC BY - NC 4.0)发布。如需详细信息,请查阅 LICENSE.md 文件。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client