npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

weather-services-mcp

v1.1.1

Published

通用天气 MCP 服务器,支持多个天气 API 供应商(例如 wttr.in、心知天气)

Readme

Weather Services MCP Server

通用天气 MCP 服务器,支持多个天气 API 供应商(例如 wttr.in、心知天气)。

安装

npm install
npm run build

使用方法

本地测试

npm run dev

配置供应商

本项目支持两个后端:

  • wttr(默认)- 通过 wttr.in 查询天气
  • seniverse - 使用心知天气 API

在启动服务器前通过环境变量设置:

# 使用 wttr
export VENDOR=wttr

# 使用 seniverse 并指定 api key
export VENDOR=seniverse
export SENIVERSE_API_KEY=你的密钥

对应的 Claude Desktop 配置中也可以在 commandargs 前面加上 env 字段,传递这些变量。

在 Claude Desktop 中配置

编辑 Claude Desktop 配置文件:

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

添加以下配置:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/你的项目路径/weather-services-mcp/build/index.js"]
    }
  }
}

功能

⚠️ 如果选择 seniverse 作为供应商,必须提供 SENIVERSE_API_KEY。请参阅 docs/seniverse-api.md 了解接口详情。

示例

使用 wttr(默认):

VENDOR=wttr node build/index.js
> get_weather {"location":"Beijing","format":"text"}
天气内容...

使用 seniverse:

VENDOR=seniverse SENIVERSE_API_KEY=xxx node build/index.js
> get_weather {"location":"Shanghai","format":"json"}
{ "results": [ ... ] }
> get_forecast {"location":"上海"}
位置: 上海, 中国
今日天气:白天 多云,夜间 晴
...

功能

⚠️ 如果选择 seniverse 作为供应商,必须提供 SENIVERSE_API_KEY。请参考 docs/seniverse-api.md 了解接口详情。

工具:get_weather

获取指定地点的天气信息或预报

参数:

  • location (必需): 位置(城市名、邮编、机场代码等),例如:Beijing, Shanghai, 10001
  • type (可选): 返回类型 - "current"(当前天气)或 "forecast"(天气预报),默认为 "forecast"
  • format (可选): 输出格式 - "text"(文本)或 "json"(JSON),默认为 "text"

示例:

获取北京的当前天气:{ location: "Beijing", type: "current", format: "json" }
获取上海的天气预报:{ location: "Shanghai", type: "forecast" }

支持的位置格式

  • 城市名称: Beijing, Shanghai, 北京, 上海

技术栈

  • TypeScript
  • MCP SDK
  • wttr.in API / 心知天气 API

架构说明

供应商相关的请求与解析逻辑分别放在 src/vendors/wttr.tssrc/vendors/seniverse.tsindex.ts 仅负责根据环境配置选择模块并组合工具。

测试

项目包含一个 Node.js 脚本用于验证 MCP 服务器功能(同时对 wttrseniverse 两种供应商进行测试)。

node tests/test_mcp_server.js node build/index.js

该脚本会依次跑 wttrseniverse 两个场景。

⚠️ 若希望测试 seniverse 模式,必须通过环境变量设定 SENIVERSE_API_KEY,否则脚本会输出警告并测试可能失败。

终端输出会显示各项 RPC 调用结果和最终通过/失败状态。脚本执行返回代码为 0 表示所有测试通过。

许可证

MIT