
azure-samples/remote-mcp-webapp-python-auth-oauth
Developer toolsこのページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る
国立気象サービスAPIを使用して気象情報を提供するFastAPIで構築されたModel Context Protocol(MCP)サーバーです.
概要
国立気象サービスAPIを使用して気象情報を提供するFastAPIで構築されたModel Context Protocol(MCP)サーバーです。 PKCE、動的クライアントの登録、およびAzure ADの統合の特長。 Azure Developer CLI(azd)でAzure App Serviceにデプロイする準備ができました。 - : MCP認証仕様(2025-03-26)の完全実装 - : コード交換(RFC 7636、S256メソッド)のプルーフキーによるセキュアな認証 - : RFC 7591ごとの自動クライアント登録 - : RFC 8414ごとのディスカバリーエンドポイント - : Azure ADを認可サーバーとして使用 - : MCP-Protocol-Versionのフルサポート:2025-03-26 - : セキュアなトークンベースの認証 - : - get alert: 米国の状態のアラートをゲット - Azure ADを認証サーバーとして取得する - : 詳細な天気予報 - OCP-Protocol-Version: 既定の有効期限: OAuth-Auth 詳細なサービス: このサーバーは、完全なMCP認証仕様(2025-03-26)を実行します。 - 取得/.
概要(AI 翻訳)
国立気象サービスAPIを使用して気象情報を提供するFastAPIで構築されたModel Context Protocol(MCP)サーバーです。 特徴フルMCP OAuth 2.1準拠 PKCE、動的クライアント登録、およびAzure AD統合。 Azure Developer CLI(azd)でAzure App Serviceにデプロイする準備ができました。
✔ 機能
- MCP OAuth 2.1 仕様準拠:MCP認証仕様の完全実装(2025-03-26) -PKCE必須:コード交換(RFC 7636、S256メソッド)のプルーフキーで安全な認可
- ダイナミッククライアント登録: RFC 7591ごとの自動クライアント登録 -Authorization Server Metadata:RFC 8414ごとのディスカバリーエンドポイント
- 第三者の認可: Azure AD を認可サーバーとして使用
- MCPプロトコルヘッダ: [
MCP-Protocol-Version: 2025-03-26のフルサポート - JWTトークン管理: セキュアトークンベースの認証
- 天候用具:
- [
get_forecast: あらゆる場所の詳細な天気予報を入手 -Azure Ready:Azure App Serviceのデプロイ用に事前設定 -Webテストインターフェイス:作り付けOAuth 2.1の流れのテスト
このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。
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 stateget_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 refreshGET /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
-
Complete OAuth setup first: Follow the instructions in AUTH_SETUP.md to create your Azure App Registration.
-
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 -
Configure environment variables:
インストール
npx @modelcontextprotocol/inspector設定
{
"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"
}
}
}