Skip to main content
Glama
sauravkumar329

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: MCP Authentication Example

프로젝트 구조

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 table

2 — 환경 구성

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

3 — 실행

로컬:

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

서버가 http://0.0.0.0:8000에서 시작됩니다.

AWS ECS Express 모드로 배포:

전체 가이드는 docs/deploy-ecs-express.md를 참조하세요. 이미지를 빌드하고 ECR에 푸시하며 자동 확장이 포함된 공용 HTTPS 서비스를 생성합니다.


API 엔드포인트

엔드포인트

인증

설명

GET /health

없음

상태 확인

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

없음

RFC 9728 검색 문서

POST /register

없음

RFC 7591 동적 클라이언트 등록

POST /mcp

Bearer 토큰

MCP 도구 (스트리밍 가능 HTTP)


MCP 도구

도구

설명

get_current_weather

위도/경도를 통해 모든 위치의 현재 날씨 확인


사용법

동적 클라이언트 등록 (사전 구성 불필요)

# 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}'

환경 변수

변수

설명

COGNITO_REGION

AWS 리전 (예: us-east-1)

COGNITO_USER_POOL_ID

Cognito 사용자 풀 ID

COGNITO_DOMAIN_PREFIX

호스팅된 UI 도메인 접두사

SERVER_URL

이 서버의 공용 URL (기본값: http://localhost:8000)


인증 작동 방식

  1. 토큰 없이 /mcp로 요청이 도착하면 → 서버는 401 응답과 함께 /.well-known/oauth-protected-resource를 가리키는 WWW-Authenticate 헤더를 반환합니다.

  2. 클라이언트는 검색 문서를 가져와 Cognito 권한 부여 서버를 찾습니다.

  3. 클라이언트는 Cognito로부터 JWT 액세스 토큰을 획득합니다 (client_credentials 또는 동적 클라이언트 등록을 통해).

  4. 클라이언트는 후속 요청에 Authorization: Bearer <token>을 포함합니다.

  5. 미들웨어는 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 모드로 배포할 때 이미지는 다이제스트로 고정됩니다. 업데이트 방법은 배포 가이드를 참조하세요.


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