weather-mcp-server

xiaoyuchenhot/weather-mcp-server

3.2

If you are the rightful owner of weather-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A simple Model Context Protocol (MCP) server built with TypeScript that provides weather information using the Open-Meteo API.

Tools
2
Resources
0
Prompts
0

Weather MCP Server

A simple Model Context Protocol (MCP) server built with TypeScript that provides weather information using the Open-Meteo API.

Features

  • 🌤️ Get Weather: Fetch current weather data for any city worldwide
  • 👋 Greet: Simple greeting tool for testing
  • 🌍 Uses free Open-Meteo API (no API key required)
  • 🚀 Built with MCP TypeScript SDK
  • 📡 HTTP transport support

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

  1. Install dependencies:
npm install

Usage

Development Mode

Run the server with auto-reload:

npm run dev

Production Mode

  1. Build the TypeScript code:
npm run build
  1. Start the server:
npm start

The server will start on http://localhost:3000/mcp by default. You can change the port by setting the PORT environment variable:

PORT=8080 npm run dev

Connecting to the Server

Using MCP Inspector

The easiest way to test your server:

npx @modelcontextprotocol/inspector

Then connect to: http://localhost:3000/mcp

Using Claude Code

claude mcp add --transport http weather-server http://localhost:3000/mcp

Using VS Code

code --add-mcp "{\"name\":\"weather-server\",\"type\":\"http\",\"url\":\"http://localhost:3000/mcp\"}"

Using Cursor

Click

Available Tools

1. get-weather

Get current weather information for any city.

Input:

{
  "city": "Sydney"
}

Output:

{
  "city": "Sydney, Australia",
  "temperature": 22.5,
  "weatherCode": 0,
  "windSpeed": 15.2,
  "humidity": 65,
  "description": "Clear sky"
}

Example queries:

  • "What's the weather in Tokyo?"
  • "Get me the current temperature in London"
  • "How's the weather in New York?"

2. greet

Simple greeting tool for testing the server.

Input:

{
  "name": "Alice"
}

Output:

{
  "greeting": "Hello, Alice! Welcome to the Weather MCP Server!"
}

API Information

This server uses the free Open-Meteo API which provides:

  • Current weather conditions
  • No API key required
  • Global coverage
  • Reliable geocoding

Project Structure

weather-mcp-server/
├── src/
│   └── index.ts          # Main server implementation
├── dist/                 # Compiled JavaScript (generated)
├── package.json          # Dependencies and scripts
├── tsconfig.json         # TypeScript configuration
└── README.md            # This file

Development

The server is built using:

  • @modelcontextprotocol/sdk: MCP TypeScript SDK
  • Express: HTTP server
  • Zod: Schema validation
  • TypeScript: Type safety

Health Check

The server includes a health check endpoint:

curl http://localhost:3000/health

Response:

{
  "status": "ok",
  "server": "weather-mcp-server",
  "version": "1.0.0"
}

Troubleshooting

Port already in use

If port 3000 is already in use, specify a different port:

PORT=8080 npm run dev

City not found

Make sure you're using the correct city name. The API uses geocoding to find cities, so try:

  • Full city names: "New York" instead of "NYC"
  • Including country if ambiguous: "London, UK" or "London, Ontario"

License

MIT