Weather MCP Server
Enables secure retrieval of real-time weather data for any location via Open-Meteo using AWS Cognito OAuth 2.1 Bearer token authentication. Implements full MCP Authorization Specification with dynamic client registration and protected resource metadata discovery.
README
Weather MCP Server
A Model Context Protocol server that provides real-time weather data, secured with AWS Cognito OAuth 2.1 Bearer token authentication.
Implements the full MCP Authorization Specification (2025-11-25):
- RFC 9728 — Protected Resource Metadata (PRM) discovery
- RFC 6750 — Bearer token usage
- RFC 7591 — Dynamic Client Registration (DCR) bridged to Cognito
Architecture
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
Weather data is sourced from Open-Meteo — free, no API key required.
Project Structure
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
Prerequisites
- Python 3.13+ and uv
- AWS account with CLI configured (
aws configure) - Docker (optional, for containerised deployment)
Quick Start
1 — Deploy AWS Cognito
aws cloudformation deploy \
--template-file infra/cognito.yaml \
--stack-name weather-mcp \
--region us-east-1 \
--capabilities CAPABILITY_NAMED_IAM
Get the output values:
aws cloudformation describe-stacks \
--stack-name weather-mcp \
--query "Stacks[0].Outputs" \
--output table
2 — Configure environment
cp .env.example .env
# Fill in COGNITO_REGION, COGNITO_USER_POOL_ID, COGNITO_DOMAIN_PREFIX from CloudFormation Outputs
3 — Run
Locally:
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
Server starts at http://0.0.0.0:8000.
Deploy to AWS ECS Express Mode:
See docs/deploy-ecs-express.md for the full guide — builds the image, pushes to ECR, and creates a public HTTPS service with auto scaling.
API Endpoints
| Endpoint | Auth | Description |
|---|---|---|
GET /health |
None | Health check |
GET /.well-known/oauth-protected-resource |
None | RFC 9728 discovery document |
POST /register |
None | RFC 7591 Dynamic Client Registration |
POST /mcp |
Bearer token | MCP tools (streamable HTTP) |
MCP Tools
| Tool | Description |
|---|---|
get_current_weather |
Current weather for any location by latitude/longitude |
Usage
Dynamic Client Registration (zero pre-configuration)
# 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}'
Environment Variables
| Variable | Description |
|---|---|
COGNITO_REGION |
AWS region (e.g. us-east-1) |
COGNITO_USER_POOL_ID |
Cognito User Pool ID |
COGNITO_DOMAIN_PREFIX |
Hosted-UI domain prefix |
SERVER_URL |
Public URL of this server (default: http://localhost:8000) |
How Authentication Works
- A request arrives at
/mcpwithout a token → server responds with401and aWWW-Authenticateheader pointing to/.well-known/oauth-protected-resource - The client fetches the discovery document to find the Cognito authorization server
- The client obtains a JWT access token from Cognito (via
client_credentialsor Dynamic Client Registration) - The client includes
Authorization: Bearer <token>on subsequent requests - The middleware validates the JWT signature against Cognito's JWKS endpoint (RS256, cached 1 hour)
Notes
- The MCP server binds to
0.0.0.0:8000with DNS rebinding protection disabled (host="0.0.0.0"). This is required when running behind a load balancer (e.g. ECS Express Mode ALB) where theHostheader is the public domain, notlocalhost. - When deploying to ECS Express Mode, the image is pinned by digest — see the deployment guide for how to update it.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。