Back to MCP directory
publicPublicdnsLocal runtime

mcp-o7b

一个基于FastMCP构建的天气查询服务器,提供全球城市天气信息查询服务,支持温度单位切换和完整日志记录。

article

README

🚀 天气 MCP 服务器

这是一个基于 FastMCP 构建的天气查询服务器,能为用户提供全球城市的天气信息查询服务,满足不同用户对天气数据的需求。

✨ 主要特性

  • 🌍 支持全球城市天气查询,无论您身处何地,都能轻松获取当地天气。
  • 🌡️ 提供温度、湿度和天气描述信息,让您全面了解天气状况。
  • 🔄 支持摄氏度和华氏度温度单位切换,满足不同用户的使用习惯。
  • 🛠️ 基于 Model Context Protocol (MCP) 实现,确保系统的高效稳定运行。
  • 📝 完整的日志记录,方便后续问题排查和系统优化。

📦 安装指南

安装要求

  • Python 3.8+
  • OpenWeatherMap API 密钥
  • uv (Python 包管理工具)

🚀 快速开始

  1. 克隆仓库:
git clone <repository-url>
cd weather-mcp-server
  1. 安装依赖:
make install
  1. 设置环境变量: 创建 .env 文件并添加以下内容:
OPENWEATHER_API_KEY=你的OpenWeatherMap_API密钥
  1. 运行服务器:
make run

💻 使用示例

选项 1:使用 uvx(推荐)

使用 uvx 可以自动从 PyPI 安装包,无需克隆仓库。将以下配置添加到 Claude Desktop 的配置文件 claude_desktop_config.json 中:

{
  "mcpServers": {
    "weather-mcp-server": {
      "command": "uvx",
      "args": [
        "weather-mcp-server"
      ],
      "env": {
        "OPENWEATHER_API_KEY": "你的OpenWeatherMap_API密钥"
      }
    }
  }
}

选项 2:本地开发模式

  1. 克隆仓库并安装依赖:
git clone <repository-url>
cd weather-mcp-server
make install
  1. 设置环境变量: 创建 .env 文件并添加以下内容:
OPENWEATHER_API_KEY=你的OpenWeatherMap_API密钥
  1. 在 Claude Desktop 配置文件中添加:
{
  "mcpServers": {
    "weather": {
      "command": "uv",
      "args": [
        "--directory",
        "path/to/src/weather_mcp_server",
        "run",
        "weather-mcp-server"
      ],
      "env": {
        "OPENWEATHER_API_KEY": "你的OpenWeatherMap_API密钥"
      }
    }
  }
}

配置文件位置:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

重启 Claude Desktop 以加载新的 MCP 服务器。

🔧 技术细节

开发

本项目使用 Makefile 来简化常用命令。

可用命令

make install  # 安装依赖
make format   # 格式化代码
make lint     # 运行代码检查
make clean    # 清理临时文件
make run      # 运行服务器

发布新版本

make release version=v0.1.0

📚 详细文档

MCP 工具

服务器提供以下 MCP 工具:

get_weather

获取指定城市的天气信息。

参数:

  • city: 城市名称(必填)
  • units: 温度单位(可选,默认为 "metric")
    • "metric": 摄氏度
    • "imperial": 华氏度

示例请求:

{
    "name": "get_weather",
    "kwargs": {
        "city": "Beijing",
        "units": "metric"
    }
}

示例响应:

{
    "temperature": 20.5,
    "humidity": 65,
    "description": "晴",
    "city": "Beijing"
}

现在您可以通过 Claude 使用自然语言查询天气,例如:

  • "北京的天气如何?"
  • "纽约当前的温度是多少?"
  • "告诉我大阪的天气情况。"
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