Skip to main content
Glama
sauravkumar329

Weather MCP Server

Wetter-MCP-Server

Ein Model Context Protocol-Server, der Echtzeit-Wetterdaten bereitstellt und mit AWS Cognito OAuth 2.1 Bearer-Token-Authentifizierung gesichert ist.

Implementiert die vollständige MCP-Autorisierungsspezifikation (25.11.2025):

  • RFC 9728 — Erkennung geschützter Ressourcen-Metadaten (PRM)

  • RFC 6750 — Verwendung von Bearer-Tokens

  • RFC 7591 — Dynamische Client-Registrierung (DCR), verbunden mit Cognito


Architektur

Client / AI Agent
  │
  ├─ GET  /.well-known/oauth-protected-resource   → discover auth server
  ├─ POST /register                               → dynamic client registration (optional)
  ├─ POST Cognito /oauth2/token                   → exchange credentials for JWT
  └─ POST /mcp   Authorization: Bearer <token>    → call MCP tools

Wetterdaten werden von Open-Meteo bezogen — kostenlos, kein API-Schlüssel erforderlich.


Related MCP server: MCP Authentication Example

Projektstruktur

weather-mcp/
├── weather_mcp/
│   ├── __init__.py
│   ├── config.py       # Env var loading (COGNITO_REGION/USER_POOL_ID/DOMAIN_PREFIX, SERVER_URL)
│   ├── auth.py         # JWT validation, middleware, PRM + DCR handlers
│   ├── tools.py        # MCP instance + weather tools
│   └── main.py         # Starlette app factory + uvicorn entrypoint
├── infra/
│   └── cognito.yaml    # CloudFormation — Cognito User Pool, IAM role
├── docs/
│   └── deploy-ecs-express.md  # ECS Express Mode deployment guide
├── pyproject.toml
├── Dockerfile
├── .env.example
└── README.md

Voraussetzungen

  • Python 3.13+ und uv

  • AWS-Konto mit konfiguriertem CLI (aws configure)

  • Docker (optional, für containerisierte Bereitstellung)


Schnellstart

1 — AWS Cognito bereitstellen

aws cloudformation deploy \
  --template-file infra/cognito.yaml \
  --stack-name weather-mcp \
  --region us-east-1 \
  --capabilities CAPABILITY_NAMED_IAM

Die Ausgabewerte abrufen:

aws cloudformation describe-stacks \
  --stack-name weather-mcp \
  --query "Stacks[0].Outputs" \
  --output table

2 — Umgebung konfigurieren

cp .env.example .env
# Fill in COGNITO_REGION, COGNITO_USER_POOL_ID, COGNITO_DOMAIN_PREFIX from CloudFormation Outputs

3 — Ausführen

Lokal:

uv sync
uv run python -m weather_mcp.main

Docker:

docker build -t weather-mcp:local .
docker run --env-file .env -p 8000:8000 weather-mcp:local

Der Server startet unter http://0.0.0.0:8000.

Bereitstellung im AWS ECS Express-Modus:

Siehe docs/deploy-ecs-express.md für die vollständige Anleitung — erstellt das Image, pusht es zu ECR und erstellt einen öffentlichen HTTPS-Dienst mit Auto-Scaling.


API-Endpunkte

Endpunkt

Authentifizierung

Beschreibung

GET /health

Keine

Gesundheitsprüfung

GET /.well-known/oauth-protected-resource

Keine

RFC 9728 Discovery-Dokument

POST /register

Keine

RFC 7591 Dynamische Client-Registrierung

POST /mcp

Bearer-Token

MCP-Tools (streambares HTTP)


MCP-Tools

Tool

Beschreibung

get_current_weather

Aktuelles Wetter für jeden Standort nach Breitengrad/Längengrad


Verwendung

Dynamische Client-Registrierung (keine Vorkonfiguration erforderlich)

# 1. Register a new client
curl -s -X POST http://localhost:8000/register \
  -H "Content-Type: application/json" \
  -d '{"client_name":"my-agent","grant_types":["client_credentials"],"scope":"weather-mcp/read"}'

# 2. Get a token
curl -s -X POST https://weather-mcp-auth.auth.us-east-1.amazoncognito.com/oauth2/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&scope=weather-mcp/read"

# 3. Call MCP
curl -s -X POST http://localhost:8000/mcp \
  -H "Authorization: Bearer <TOKEN>" \
  -H "Accept: application/json, text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'

Umgebungsvariablen

Variable

Beschreibung

COGNITO_REGION

AWS-Region (z. B. us-east-1)

COGNITO_USER_POOL_ID

Cognito User Pool ID

COGNITO_DOMAIN_PREFIX

Hosted-UI-Domain-Präfix

SERVER_URL

Öffentliche URL dieses Servers (Standard: http://localhost:8000)


Funktionsweise der Authentifizierung

  1. Eine Anfrage trifft ohne Token bei /mcp ein → der Server antwortet mit 401 und einem WWW-Authenticate-Header, der auf /.well-known/oauth-protected-resource verweist.

  2. Der Client ruft das Discovery-Dokument ab, um den Cognito-Autorisierungsserver zu finden.

  3. Der Client erhält ein JWT-Zugriffstoken von Cognito (via client_credentials oder dynamischer Client-Registrierung).

  4. Der Client fügt bei nachfolgenden Anfragen Authorization: Bearer <token> hinzu.

  5. Die Middleware validiert die JWT-Signatur gegen den JWKS-Endpunkt von Cognito (RS256, 1 Stunde zwischengespeichert).


Hinweise

  • Der MCP-Server bindet an 0.0.0.0:8000 mit deaktiviertem DNS-Rebinding-Schutz (host="0.0.0.0"). Dies ist erforderlich, wenn der Betrieb hinter einem Load Balancer (z. B. ECS Express Mode ALB) erfolgt, bei dem der Host-Header die öffentliche Domain und nicht localhost ist.

  • Bei der Bereitstellung im ECS Express-Modus ist das Image per Digest fixiert — siehe die Bereitstellungsanleitung für Informationen zur Aktualisierung.


F
license - not found
Not graded
quality - not tested
D
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

  • NOAA and ECMWF weather forecast MCP for discovery, validation, and GribStream OAuth queries.

  • Open-Meteo MCP — weather forecast + historical reanalysis + sister APIs

  • OpenWeather MCP — wraps the OpenWeatherMap API (openweathermap.org)

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/sauravkumar329/weather-mcp'

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