Weather Server Js
FreeNot checkedA remote MCP server that exposes a get_weather tool for real-time current weather queries of any city via the free wttr.in API, supporting Streamable HTTP trans
About
A remote MCP server that exposes a get_weather tool for real-time current weather queries of any city via the free wttr.in API, supporting Streamable HTTP transport.
README
基于 Node.js / Express 实现的远程 MCP (Model Context Protocol) 服务器。
通过 Streamable HTTP transport 暴露 get_weather 工具,让 Claude Code 等 MCP 客户端可以实时查询任意城市的当前天气。
天气数据来自 wttr.in —— 免费、无需注册、无需 API key。
✨ 功能特性
- 🛰️ 远程 MCP 服务:基于官方
@modelcontextprotocol/sdk实现 Streamable HTTP 传输,支持 JSON 与 SSE 两种响应模式 - 🌆 全球城市支持:直接传城市名(如
Beijing、Tokyo、Paris)即可查询当地天气 - 🔌 完整会话管理:自动生成/校验
Mcp-Session-Id,支持会话的建立、复用与关闭(DELETE) - 🧩 单文件即用:无需数据库,零配置文件,一个
server.js即可启动
📦 环境要求
- Node.js ≥ 18(内置
fetch,无需额外依赖)
🚀 快速开始
# 1. 安装依赖
npm install
# 2. 启动服务(默认端口 3000)
npm start
# 后台运行(日志写入 logs/server.log)
npm run start:bg
启动成功后,服务地址为:
http://localhost:3000/mcp
常用脚本
| 命令 | 说明 |
|---|---|
npm start |
前台启动服务 |
npm start:bg |
后台启动,日志写入 logs/server.log |
npm run dev |
开发模式,文件变更自动重启 |
npm run status |
查看 3000 端口服务是否在运行 |
npm run logs |
实时查看日志 |
npm run stop |
停止服务 |
npm run restart |
重启服务 |
npm run restart:bg |
后台重启 |
🔌 配置 MCP 客户端
在 Claude Code 或其他支持 Streamable HTTP 的 MCP 客户端中,将服务注册为远程 MCP 服务器。
Claude Code
通过 MCP 服务器列表添加(/mcp → 添加 → HTTP):
{
"type": "http",
"url": "http://localhost:3000/mcp"
}
JSON 配置文件方式
{
"mcpServers": {
"weather": {
"type": "http",
"url": "http://localhost:3000/mcp"
}
}
}
🧰 提供的工具
get_weather
获取指定城市的当前天气情况。
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
city |
string | ✅ | 城市名称,例如 Beijing、Tokyo |
返回示例
当前 Beijing 的天气是晴(Sunny),温度 28°C(体感 30°C),湿度 45%,风速 12 km/h。
⚙️ 实现说明
- 会话隔离:每个会话持有独立的
Server+transport实例(SDK 的connect()只支持一个 transport),通过Mcp-Session-Id请求头关联。 - 新会话流程:不带
Mcp-Session-Id的 POST 视为初始化请求,服务器生成会话 ID 并通过Mcp-Session-Id响应头返回(通过 CORS 的exposedHeaders显式暴露给浏览器客户端)。 - 兼容性处理:无会话 ID 的 GET SSE 探测请求会保持一个打开的 SSE 流(而非返回 404/400),让 Claude Code 等客户端可以继续走 POST 初始化流程。
- 可靠的错误返回:天气 API 调用失败时返回
isError: true的结果而非让整个请求崩溃。
🗂️ 项目结构
.
├── server.js # 全部服务逻辑(单文件)
├── package.json # 项目配置与脚本
├── logs/ # 运行时日志(已被 .gitignore 忽略)
└── LICENSE # MIT 许可证
📄 License
Installing Weather Server Js
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/yuxiaosenstar/weather-mcp-server-jsFAQ
Is Weather Server Js MCP free?
Yes, Weather Server Js MCP is free — one-click install via Unyly at no cost.
Does Weather Server Js need an API key?
No, Weather Server Js runs without API keys or environment variables.
Is Weather Server Js hosted or self-hosted?
A hosted option is available: Unyly runs the server in the cloud, no local setup required.
How do I install Weather Server Js in Claude Desktop, Claude Code or Cursor?
Open Weather Server Js on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
GitHub
PRs, issues, code search, CI status
by GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
by mcpdotdirectAmap Maps Mcp Server
MCP server for using the AMap Maps API
by duxiaohuiSupabase
Database, auth and storage
by SupabaseEverything
Reference / test server with prompts, resources, and tools.
Git
Tools to read, search, and manipulate Git repositories.
Sequential Thinking
Dynamic and reflective problem-solving through thought sequences.
Time
Time and timezone conversion capabilities.
Compare Weather Server Js with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All development MCPs
