weather-mcp

weather-mcp

Provides US weather alerts by state and forecasts by coordinates using the National Weather Service API.

Category
访问服务器

README

Weather MCP Server + MCP Log Proxy

两个 MCP (Model Context Protocol) 工具,通过 stdio 协议与 MCP 客户端(如 Claude Code、Cline、VS Code 等)交互。

weather-mcp/
├── weather.py           # Weather MCP 服务器 — 查美国天气
├── main.py              # 占位入口
├── pyproject.toml        # 项目依赖
├── README.md
└── mcpLog/
    ├── mcp_log.py        # MCP Log Proxy — 透明代理记录请求/响应
    └── pyproject.toml    # proxy 依赖

1. Weather MCP Server

提供两个工具,数据来源 weather.gov API。

安装

# 安装 uv(如果还没有)
pip install uv

# 同步依赖
uv sync

工具

工具 参数 说明
get_alerts state: string 查询美国州的天气警报(两字母州代码,如 CA)
get_forecast latitude: float, longitude: float 查询经纬度处的天气预报

运行

uv run weather.py

2. MCP Log Proxy

透明 stdio 代理,记录 MCP 客户端与目标服务器之间的所有 JSON-RPC 流量。

Client ≤stdin/stdout≥ mcp_log.py ≤stdio≥ Target Server
                              │
                        logs/<timestamp>_<pid>.jsonl

安装

cd mcpLog
uv sync

命令行用法

python mcp_log.py <target_command> [target_args...] [--log-dir <dir>]

示例 — 代理 weather 服务器:

python mcp_log.py python ../weather.py --log-dir ./logs

日志格式

每行一个 JSON 对象,字段:

字段 说明
ts UTC 时间戳
dir META(元信息)/ REQUEST >>(请求)/ RESPONSE <<(响应)
msg 完整的 JSON-RPC 消息体

示例:

{"ts":"2026-06-13T15:17:31","dir":"REQUEST  >>","msg":{"method":"tools/call","params":{"name":"get_alerts","arguments":{"state":"CA"}},"jsonrpc":"2.0","id":5}}
{"ts":"2026-06-13T15:17:38","dir":"RESPONSE <<","msg":{"jsonrpc":"2.0","id":5,"result":{"content":[{"type":"text","text":"..."}]}}}

3. 配置 Cline(VS Code 插件)

编辑 %APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json

直连 weather(不打日志)

{
  "mcpServers": {
    "weather": {
      "autoApprove": ["get_forecast", "get_alerts"],
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "uv",
      "args": [
        "--directory",
        "C:\\code\\python\\weather",
        "run",
        "weather.py"
      ]
    }
  }
}

通过 proxy 连接(记录所有请求日志)

{
  "mcpServers": {
    "weather": {
      "autoApprove": ["get_forecast", "get_alerts"],
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "C:\\code\\python\\weather\\mcpLog\\.venv\\Scripts\\python.exe",
      "args": [
        "C:\\code\\python\\weather\\mcpLog\\mcp_log.py",
        "C:\\code\\python\\weather\\.venv\\Scripts\\python.exe",
        "C:\\code\\python\\weather\\weather.py",
        "--log-dir",
        "C:\\code\\python\\weather\\mcpLog\\logs"
      ]
    }
  }
}

注意:路径里的 .venv\Scripts\python.exe 是 Windows 的 venv 路径,macOS/Linux 改为 .venv/bin/python

配置后 reload Cline(或重启 VS Code)即可生效,日志输出到 mcpLog/logs/ 目录。


4. 配置 Claude Code

在项目根目录创建 .mcp.json

{
  "mcpServers": {
    "weather": {
      "type": "stdio",
      "command": "python",
      "args": [
        "mcpLog/mcp_log.py",
        "python",
        "weather.py",
        "--log-dir",
        "mcpLog/logs"
      ]
    }
  }
}

依赖

  • Python ≥ 3.13
  • MCP SDK ≥ 1.27
  • httpx
  • anyio

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选