关于 Smarter Weather
Smarter Weather 是一个 stdio 到 Streamable HTTP 的桥接客户端,帮助本地 MCP 客户端连接 Smarter Weather 托管服务。它负责传递 API 密钥和 MCP 消息,天气工具与数据由远程服务提供。
主要功能
- 01连接托管天气 MCP 服务
- 02从环境变量或 .env 读取密钥
- 03转发 mcp-remote 参数
- 04支持自定义 MCP 端点
适用场景
- 01在 Claude Desktop 中调用天气服务
- 02让 Cursor 连接远程天气 MCP
- 03为本地 MCP 客户端配置 API 密钥
MCP 相关
该客户端通过 stdio 接收 MCP 消息,并代理至 Smarter Weather 的 Streamable HTTP 端点。它不实现天气逻辑,工具和模式由远程 MCP 服务提供。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://mcp.smarterweather.comclaude mcp add --transport http smarterweather-weather https://mcp.smarterweather.com{"mcpServers":{"smarterweather-weather":{"type":"http","url":"https://mcp.smarterweather.com"}}}在 Cursor 中打开{"servers":{"smarterweather-weather":{"type":"http","url":"https://mcp.smarterweather.com"}}}在 VS Code 中打开{"mcpServers":{"smarterweather-weather":{"type":"http","url":"https://mcp.smarterweather.com"}}}{"mcpServers":{"smarterweather-weather":{"serverUrl":"https://mcp.smarterweather.com"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
工具
14| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| fuzzy | boolean | 否 | 部分匹配或拼写错误输入的自动建议模式。默认值为 false(精确搜索)。 |
| limit | integer | 否 | 最多返回的候选项数(1–10)。默认值为 5。 |
| query | string | 是 | 地点查询:城市、"city, state"、ZIP、部分文本,或在已启用时使用场馆/地址。 |
| near_lat | number | 否 | 按此点附近的场馆/地址排序;需与 near_lon 配对使用。 |
| near_lon | number | 否 |
详细介绍
@smarterweather/mcp-weather
一个 stdio 到 Streamable HTTP 的桥接程序,用于连接 Smarter Weather 托管的 MCP 服务 https://mcp.smarterweather.com。它让仅支持本地连接的 MCP 客户端(Claude Desktop、Claude Code、Cursor、MCP Inspector 等)能够通过网络使用你的 API 密钥访问 sw-mcp。
需要 Node.js 22 或更高版本。
此软件包是 mcp-remote 的轻量封装:不包含天气相关逻辑,也不分叉协议实现。所有工具、架构、速率限制和计量都由服务端的 sw-mcp 处理。
获取 API 密钥
在项目目录中运行以下任一命令:
# A human is present: device sign-in in the browser (free account, no card)
npx -y @smarterweather/mcp-onboarding@latest login
# No human present: mint a trial key you can claim into a free account later
npx -y @smarterweather/mcp-onboarding@latest trial
这两个命令都会将 SMARTERWEATHER_API_KEY 写入 ./.env(权限模式为 0600,且已添加到 gitignore),并且只显示密钥前缀,不会显示完整密钥。
桥接程序按以下顺序查找密钥:
- 进程环境中的
SMARTERWEATHER_API_KEY SMARTERWEATHER_ENV_FILE指定的文件- 当前工作目录中的
.env(当前工作目录为/或$HOME时跳过)
未展开的 ${…} 占位符将视为未设置。桥接程序会通过 Authorization:${SMARTERWEATHER_AUTH_HEADER} 将密钥传递给 mcp-remote,Bearer 密钥仅存在于子进程环境中,不会出现在 argv 中。
即使没有密钥,桥接程序仍会连接,search_locations 和 search_catalog 等发现工具也仍可免费使用。调用其他工具时会返回 x402 付款要求(Base 上的 USDC),其中的 next_steps 会引导你返回 login 和 trial。目前桥接程序不支持通过 OAuth 登录;请使用 API 密钥。
安装
npx -y @smarterweather/mcp-weather --version
Claude Desktop
将以下内容添加到 claude_desktop_config.json(macOS:~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"smarterweather": {
"command": "npx",
"args": ["-y", "@smarterweather/mcp-weather"],
"env": {
"SMARTERWEATHER_ENV_FILE": "/absolute/path/to/your/project/.env"
}
}
}
}
Claude Desktop 不会插值环境变量占位符,因此请使用绝对路径,让桥接程序指向 login / trial 写入的 .env。切勿将密钥粘贴到此文件中。桥接程序会在每个代理请求中发送 Authorization: Bearer <key>。
Cursor
在项目的 .cursor/mcp.json 中使用 envFile(envFile 需要 "type": "stdio"):
{
"mcpServers": {
"smarterweather": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@smarterweather/mcp-weather"],
"envFile": "${workspaceFolder}/.env"
}
}
}
或者使用进程环境中的 ${env:NAME}:
{
"mcpServers": {
"smarterweather": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@smarterweather/mcp-weather"],
"env": {
"SMARTERWEATHER_API_KEY": "${env:SMARTERWEATHER_API_KEY}"
}
}
}
}
环境变量
| 变量 | 用途 | 默认值 |
|---|---|---|
SMARTERWEATHER_API_KEY | API 密钥。设置后优先使用;未展开的 ${…} 会回退到下一项。 | 未设置(然后依次检查 SMARTERWEATHER_ENV_FILE 和 .env) |
SMARTERWEATHER_ENV_FILE | 绝对 .env 路径;仅在进程环境中未设置密钥时读取。 | 未设置 → cwd/.env(/ 或 $HOME 除外) |
SMARTERWEATHER_MCP_URL | 覆盖目标 MCP 端点。位置参数中的 URL 优先于此变量。 | https://mcp.smarterweather.com |
任何 mcp-remote 标志都会原样传递。示例:
--debug:在~/.mcp-auth/{server_hash}_debug.log中记录详细日志。--transport http-only:强制使用 Streamable HTTP(跳过 SSE 回退)。--header "X-Custom:value":添加请求头。为兼容跨平台参数转义,请使用无空格格式。
"args": [
"-y", "@smarterweather/mcp-weather",
"--debug",
"--transport", "http-only"
]
故障排查
- 工具调用返回 "Payment required":桥接程序没有找到密钥。其 stderr 会列出所有检查过的位置。在项目目录中运行
login或trial,或者将SMARTERWEATHER_ENV_FILE设为.env路径,然后重启 MCP 客户端。 - "Incompatible auth server: does not support dynamic client registration":服务端拒绝了密钥(密钥未知、已撤销或已过期),且桥接程序没有备用登录方式。使用
login或trial生成新密钥,然后重启客户端。桥接程序会原样传递密钥。 - "Connection error: fetch failed":检查你的设备是否能够访问该端点。
curl -i https://mcp.smarterweather.com应返回 HTTP405,并显示Method not allowed. Use POST.(该端点仅接受 POST)。 - Cursor 看不到服务:确保
.cursor/mcp.json是有效的 JSON,然后重启 Cursor。MCP 面板会记录已启动进程的 stderr。
工作原理
bin 是一个小型 Node 脚本。它会解析 URL(位置参数 → SMARTERWEATHER_MCP_URL → 默认值)和 API 密钥(见上文),在子进程环境中设置 SMARTERWEATHER_AUTH_HEADER,如果找到密钥,则追加 --header "Authorization:${SMARTERWEATHER_AUTH_HEADER}",然后通过 spawn() 启动 mcp-remote 的 dist/proxy.js。mcp-remote 会通过 stdio 读取 JSON-RPC,并将每条消息代理到托管的 Streamable HTTP 端点。信号(SIGINT/SIGTERM/SIGHUP)会被转发,退出代码也会传递。该包装器不会转换或检查 MCP 流量。
许可证
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。