Skip to main content
Glama
kavingas

Weather MCP Server

by kavingas
README.md
# Weather MCP Server

An example [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that exposes a `get_weather` tool, letting any MCP-compatible AI client fetch current temperatures by city name.

## How it works

1. Resolves the city name to coordinates via the [Open-Meteo Geocoding API](https://open-meteo.com/en/docs/geocoding-api)
2. Fetches the current temperature from the [Open-Meteo Forecast API](https://open-meteo.com/en/docs)

No API key required — both APIs are free and open.

## Tool

| Tool | Description | Input |
|------|-------------|-------|
| `get_weather` | Get current temperature for a city | `city` (string) |

**Example response:** `San Francisco: 14.2°C`

## Setup

```bash
npm install
```

## Running the server

```bash
node weather-server.js
```

The server communicates over **stdio** using the MCP protocol.

## Connecting to Claude Code

The repo includes a [`.mcp.json`](.mcp.json) file that Claude Code picks up automatically. When you open this directory in Claude Code, the `weather-server` MCP server is registered and the `get_weather` tool becomes available.

To connect manually, add the following to your MCP client config:

```json
{
  "mcpServers": {
    "weather-server": {
      "command": "node",
      "args": ["./weather-server.js"]
    }
  }
}
```

## Requirements

- Node.js 18+ (native `fetch` required)
- No external API keys