Weather MCP Server
날씨 MCP 서버
AWS Cognito OAuth 2.1 Bearer 토큰 인증으로 보호되는 실시간 날씨 데이터를 제공하는 Model Context Protocol 서버입니다.
전체 MCP 권한 부여 사양 (2025-11-25)을 구현합니다:
RFC 9728 — 보호된 리소스 메타데이터(PRM) 검색
RFC 6750 — Bearer 토큰 사용
RFC 7591 — Cognito에 연결된 동적 클라이언트 등록(DCR)
아키텍처
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날씨 데이터는 Open-Meteo에서 제공되며, 무료이고 API 키가 필요하지 않습니다.
Related MCP server: Python MCP Weather Server with OAuth 2.1 Authentication
프로젝트 구조
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사전 요구 사항
Python 3.13+ 및 uv
CLI가 구성된 AWS 계정 (
aws configure)Docker (선택 사항, 컨테이너 배포용)
빠른 시작
1 — AWS Cognito 배포
aws cloudformation deploy \
--template-file infra/cognito.yaml \
--stack-name weather-mcp \
--region us-east-1 \
--capabilities CAPABILITY_NAMED_IAM출력 값 가져오기:
aws cloudformation describe-stacks \
--stack-name weather-mcp \
--query "Stacks[0].Outputs" \
--output table2 — 환경 구성
cp .env.example .env
# Fill in COGNITO_REGION, COGNITO_USER_POOL_ID, COGNITO_DOMAIN_PREFIX from CloudFormation Outputs3 — 실행
로컬:
uv sync
uv run python -m weather_mcp.mainDocker:
docker build -t weather-mcp:local .
docker run --env-file .env -p 8000:8000 weather-mcp:local서버가 http://0.0.0.0:8000에서 시작됩니다.
AWS ECS Express 모드로 배포:
전체 가이드는 docs/deploy-ecs-express.md를 참조하세요. 이미지를 빌드하고 ECR에 푸시하며 자동 확장이 포함된 공용 HTTPS 서비스를 생성합니다.
API 엔드포인트
엔드포인트 | 인증 | 설명 |
| 없음 | 상태 확인 |
| 없음 | RFC 9728 검색 문서 |
| 없음 | RFC 7591 동적 클라이언트 등록 |
| Bearer 토큰 | MCP 도구 (스트리밍 가능 HTTP) |
MCP 도구
도구 | 설명 |
| 위도/경도를 통해 모든 위치의 현재 날씨 확인 |
사용법
동적 클라이언트 등록 (사전 구성 불필요)
# 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}'환경 변수
변수 | 설명 |
| AWS 리전 (예: |
| Cognito 사용자 풀 ID |
| 호스팅된 UI 도메인 접두사 |
| 이 서버의 공용 URL (기본값: |
인증 작동 방식
토큰 없이
/mcp로 요청이 도착하면 → 서버는401응답과 함께/.well-known/oauth-protected-resource를 가리키는WWW-Authenticate헤더를 반환합니다.클라이언트는 검색 문서를 가져와 Cognito 권한 부여 서버를 찾습니다.
클라이언트는 Cognito로부터 JWT 액세스 토큰을 획득합니다 (
client_credentials또는 동적 클라이언트 등록을 통해).클라이언트는 후속 요청에
Authorization: Bearer <token>을 포함합니다.미들웨어는 Cognito의 JWKS 엔드포인트(RS256, 1시간 캐시)에 대해 JWT 서명을 검증합니다.
참고 사항
MCP 서버는 DNS 리바인딩 보호가 비활성화된 상태(
host="0.0.0.0")로0.0.0.0:8000에 바인딩됩니다. 이는Host헤더가localhost가 아닌 공용 도메인인 로드 밸런서(예: ECS Express Mode ALB) 뒤에서 실행할 때 필요합니다.ECS Express 모드로 배포할 때 이미지는 다이제스트로 고정됩니다. 업데이트 방법은 배포 가이드를 참조하세요.
This server cannot be deployed
Maintenance
Related MCP Connectors
NOAA and ECMWF weather forecast MCP for discovery, validation, and GribStream OAuth queries.
Hosted MCP server for Xweather weather data: conditions, forecasts, alerts, and more.
Weather MCP — wraps Open-Meteo API (free, no auth)
Open-Meteo MCP — weather forecast + historical reanalysis + sister APIs
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceEnables real-time weather data streaming through a secure MCP server. Features authentication using Descope and can be deployed to Fly.io for remote access.4 npm-
- FlicenseNot gradedqualityDmaintenanceProvides weather information from the National Weather Service API with full MCP OAuth 2.1 compliance, including weather alerts and forecasts for US locations through secure Azure AD authentication.28-
- AlicenseNot gradedqualityDmaintenanceDemonstrates how to secure an MCP server with OAuth 2.1 using AWS Cognito, with support for dynamic client registration and client ID metadata documents.68MIT
- FlicenseNot gradedqualityDmaintenanceEnables MCP clients like Kiro and Claude to access current weather conditions and forecasts for any location using the OpenWeatherMap API.-