Skip to main content
Glama
yuxiaosenstar

weather-mcp-server-js

šŸŒ¤ļø Weather MCP Server (Node.js)

A remote MCP (Model Context Protocol) server built on Node.js / Express. It exposes the get_weather tool via Streamable HTTP transport, letting MCP clients such as Claude Code query the current weather of any city in real time.

Weather data comes from wttr.in — free, no registration, no API key required.

✨ Features

  • šŸ›°ļø Remote MCP service: Implements Streamable HTTP transport based on the official @modelcontextprotocol/sdk, supporting both JSON and SSE response modes

  • šŸŒ† Global city support: Pass a city name directly (e.g. Beijing, Tokyo, Paris) to look up local weather

  • šŸ”Œ Full session management: Automatically generates/validates Mcp-Session-Id, supporting session creation, reuse, and termination (DELETE)

  • 🧩 Single-file ready to use: No database, zero configuration files, just one server.js to get started

Related MCP server: MCP Weather Server — Demo

šŸ“¦ Requirements

  • Node.js ≄ 18 (built-in fetch, no extra dependencies)

šŸš€ Quick Start

# 1. å®‰č£…ä¾čµ–
npm install

# 2. åÆåŠØęœåŠ”(é»˜č®¤ē«Æå£ 3000)
npm start

# åŽå°čæč”Œ(旄志写兄 logs/server.log)
npm run start:bg

Once started successfully, the service address is:

http://localhost:3000/mcp

Common scripts

Command

Description

npm start

Start the service in the foreground

npm start:bg

Start in the background, logs written to logs/server.log

npm run dev

Development mode, auto-restart on file changes

npm run status

Check whether the service on port 3000 is running

npm run logs

View logs in real time

npm run stop

Stop the service

npm run restart

Restart the service

npm run restart:bg

Restart in the background

šŸ”Œ Configuring an MCP client

In Claude Code or another MCP client that supports Streamable HTTP, register the service as a remote MCP server.

Claude Code

Add it via the MCP server list (/mcp → Add → HTTP):

{
  "type": "http",
  "url": "http://localhost:3000/mcp"
}

JSON configuration file method

{
  "mcpServers": {
    "weather": {
      "type": "http",
      "url": "http://localhost:3000/mcp"
    }
  }
}

🧰 Provided tools

get_weather

Get the current weather for a specified city.

Parameters

Parameter

Type

Required

Description

city

string

āœ…

City name, e.g. Beijing, Tokyo

Example response

当前 Beijing ēš„å¤©ę°”ę˜Æę™“(Sunny),ęø©åŗ¦ 28°C(ä½“ę„Ÿ 30°C),湿度 45%,风速 12 km/h怂

āš™ļø Implementation notes

  • Session isolation: Each session holds its own Server + transport instance (the SDK's connect() only supports one transport), associated via the Mcp-Session-Id request header.

  • New session flow: A POST without Mcp-Session-Id is treated as an initialization request; the server generates a session ID and returns it via the Mcp-Session-Id response header (explicitly exposed to browser clients via CORS exposedHeaders).

  • Compatibility handling: A GET SSE probe request without a session ID keeps an open SSE stream open (instead of returning 404/400), so clients like Claude Code can continue with the POST initialization flow.

  • Reliable error responses: When the weather API call fails, it returns a result with isError: true instead of crashing the entire request.

šŸ—‚ļø Project structure

.
ā”œā”€ā”€ server.js          # å…ØéƒØęœåŠ”é€»č¾‘(å•ę–‡ä»¶)
ā”œā”€ā”€ package.json       # é”¹ē›®é…ē½®äøŽč„šęœ¬
ā”œā”€ā”€ logs/              # čæč”Œę—¶ę—„åæ—(已被 .gitignore 忽畄)
└── LICENSE            # MIT č®øåÆčÆ

šŸ“„ License

MIT

A
license - permissive license
-
quality - not tested
C
maintenance

Maintenance

–Maintainers
–Response time
–Release cycle
–Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

View all related MCP servers

Related MCP Connectors

  • AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

  • Remote ChromaDB vector database MCP server with streamable HTTP transport

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yuxiaosenstar/weather-mcp-server-js'

If you have feedback or need assistance with the MCP directory API, please join our Discord server