Skip to main content
Glama
bhavishya3102

Weather MCP Server

Weather MCP Server

An MCP (Model Context Protocol) server that provides weather tools for US locations (via NWS API) and India / global locations (via Open-Meteo API).

MCP Tools

Tool

Description

get_alerts

Weather alerts for a US state (e.g. CA, NY)

get_forecast

Forecast by latitude/longitude (NWS for US, Open-Meteo elsewhere)

get_india_weather

Current weather + 7-day forecast for an Indian city by name

Related MCP server: MCP Weather Server

Project Structure

src/
├── index.ts              # Entry point — starts the MCP server
├── server.ts             # Creates MCP server and registers all tools
│
├── config/
│   └── constants.ts      # API URLs, app name, timezone
│
├── types/
│   ├── nws.ts            # TypeScript types for US (NWS) API
│   └── open-meteo.ts     # TypeScript types for Open-Meteo API
│
├── utils/
│   ├── fetch.ts          # HTTP request helper
│   ├── location.ts       # US location detection
│   └── weather-codes.ts  # WMO weather code → readable text
│
├── formatters/
│   ├── alerts.ts         # Formats alert data into readable text
│   └── open-meteo.ts     # Formats forecast data into readable text
│
├── services/
│   ├── nws.service.ts        # US weather API calls
│   └── open-meteo.service.ts # India/global weather API + geocoding
│
└── tools/
    ├── index.ts                  # Registers all MCP tools
    ├── get-alerts.tool.ts        # US alerts tool
    ├── get-forecast.tool.ts      # Coordinates-based forecast tool
    └── get-india-weather.tool.ts # Indian city weather tool

Folder Responsibilities

Folder

Purpose

config/

App settings and constants

types/

TypeScript interfaces and types

utils/

Small reusable helper functions

formatters/

Convert API responses into human-readable text

services/

Talk to external weather APIs

tools/

MCP tool definitions (what the AI calls)

Request Flow

User / AI
   │
   ▼
index.ts          → starts server on stdio
   │
   ▼
server.ts         → creates McpServer, calls registerTools()
   │
   ▼
tools/            → handles MCP tool request (e.g. get_india_weather)
   │
   ▼
services/         → calls external API (NWS or Open-Meteo)
   │
   ▼
formatters/       → converts raw JSON into readable text
   │
   ▼
Response          → sent back to AI via MCP
flowchart TD
    A[User / AI] --> B[index.ts]
    B --> C[server.ts]
    C --> D[tools/]
    D --> E[services/]
    E --> F[External APIs]
    F --> G[formatters/]
    G --> H[MCP Response]

Setup

npm install
npm run build

Run

npm start

Cursor MCP Config

Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "weather": {
      "command": "node",
      "args": ["/absolute/path/to/weather/build/index.js"]
    }
  }
}

After changing config or code, restart the MCP server in Cursor Settings → MCP.

APIs Used

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides current weather conditions, seven-day forecasts, and US weather alerts using Open-Meteo and National Weather Service APIs. It enables users to retrieve global weather data and regional alerts without requiring any API keys.
    102 npm
    GPL 3.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides real-time weather data and alerts from the National Weather Service API, including forecasts for US locations and active alerts for US states.
    -