AS

azure-samples/remote-mcp-webapp-python-auth-oauth

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

28 stars 13 forks 품질 53 트렌드 11

A production-ready Model Context Protocol (MCP) server built with FastAPI that provides weather information using the National Weather Service API.

개요

A production-ready Model Context Protocol (MCP) server built with FastAPI that provides weather information using the National Weather Service API. Features with PKCE, dynamic client registration, and Azure AD integration. Ready for deployment to Azure App Service with Azure Developer CLI (azd). - : Complete implementation of MCP Authorization Specification (2025-03-26) - : Secure authorization with Proof Key for Code Exchange (RFC 7636, S256 method) - : Automatic client registration per RFC 7591 - : Discovery endpoint per RFC 8414 - : Uses Azure AD as authorization server - : Full support for MCP-Protocol-Version: 2025-03-26 - : Secure token-based authentication - : - get_alerts: Get weather alerts for any US state - get_forecast: Get detailed weather forecast for any location - : Pre-configured for Azure App Service deployment - : Built-in OAuth 2.1 flow testing This server implements the complete MCP Authorization Specification (2025-03-26): - GET /.

README

원문 README의 일부입니다. 원문 보기.

Python MCP Weather Server with OAuth 2.1 Authentication

A production-ready Model Context Protocol (MCP) server built with FastAPI that provides weather information using the National Weather Service API. Features full MCP OAuth 2.1 compliance with PKCE, dynamic client registration, and Azure AD integration. Ready for deployment to Azure App Service with Azure Developer CLI (azd).

🌟 Features

  • MCP OAuth 2.1 Specification Compliant: Complete implementation of MCP Authorization Specification (2025-03-26)
  • PKCE Required: Secure authorization with Proof Key for Code Exchange (RFC 7636, S256 method)
  • Dynamic Client Registration: Automatic client registration per RFC 7591
  • Authorization Server Metadata: Discovery endpoint per RFC 8414
  • Third-Party Authorization: Uses Azure AD as authorization server
  • MCP Protocol Headers: Full support for MCP-Protocol-Version: 2025-03-26
  • JWT Token Management: Secure token-based authentication
  • Weather Tools:
    • get_alerts: Get weather alerts for any US state
    • get_forecast: Get detailed weather forecast for any location
  • Azure Ready: Pre-configured for Azure App Service deployment
  • Web Test Interface: Built-in OAuth 2.1 flow testing

🔐 MCP Authorization Implementation

This server implements the complete MCP Authorization Specification (2025-03-26):

OAuth 2.1 Endpoints

  • GET /.well-known/oauth-authorization-server - Authorization server metadata (RFC 8414)
  • POST /register - Dynamic client registration (RFC 7591)
  • GET /authorize - Authorization endpoint with PKCE (RFC 7636)
  • POST /token - Token endpoint for code exchange and refresh
  • GET /auth/azure/callback - Third-party authorization callback

MCP Protocol Features

  • ✅ Protocol Version Headers: MCP-Protocol-Version: 2025-03-26
  • ✅ PKCE Required: All clients must use S256 method
  • ✅ Dynamic Registration: Automatic client onboarding
  • ✅ JWT Authentication: Bearer token validation on MCP endpoints
  • ✅ Proper Error Handling: 401/403/400 responses with details
  • ✅ Azure AD Integration: Enterprise-grade authorization server

⚠️ Important: Complete OAuth setup required before use. See AUTH_SETUP.md for Azure AD configuration instructions.

💻 Local Development

Prerequisites

  • Python 3.8+
  • Azure account with completed OAuth setup (see AUTH_SETUP.md)

Setup & Run

  1. Complete OAuth setup first: Follow the instructions in AUTH_SETUP.md to create your Azure App Registration.

  2. Clone and install dependencies:

    git clone 
    cd remote-mcp-webapp-python-auth-oauth
    python -m venv venv
    .\venv\Scripts\Activate.ps1  # Windows
    # source venv/bin/activate   # macOS/Linux
    pip install -r requirements.txt
    
  3. Configure environment variables:

GitHub에서 전체 README 보기

설치

npx @modelcontextprotocol/inspector
MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →

설정

{ "mcpServers": { "weather-mcp-server-local": { "transport": { "type": "http", "url": "http://localhost:8000/", "headers": { "Authorization": "Bearer <your-jwt-token>" } }, "name": "Weather MCP Server (Local with Auth)", "description": "Authenticated MCP Server with weather tools" } } }