LR

localden/remote-auth-mcp-apim-py

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

31 stars 13 forks 品質 54 トレンド 11MIT

Azure API Management による auth ゲート付きリモート MCP サーバー

概要

このサンプルは、Azure 上で Entra ID 保護された MCP サーバーをデプロイする方法を示しています。 このサンプルは、クライアントが最初にMCPサーバーのトークンを獲得し、on-behalf-ofフローを使用して、Microsoft Graphで使用できるトークンに交換することもできます。 完全に秘密のない方法でこれを行います。 このサンプルでは、保護されたMCPサーバーをEntra IDで構築する方法を説明します。OAuth 2.0 Dynamic Client RegisterとPKCEのフローパターンを実装することで、Entra IDのネイティブサポートにおける現在のギャップを回避できます。 技術的な可能性を秘めながら、教育と証拠の目的のみを目的としています。 生産のシナリオについては、事前登録済みのアプリケーションと標準の OAuth フローで確立された認証パターンを使用して検討してください.

概要(AI 翻訳)

このサンプルは、Azure 上で Entra ID 保護された MCP サーバーをデプロイする方法を示しています。

このサンプルは、クライアントがトークンを獲得する認可パターンを使用します。 for the MCP server 最初に、on-behalf-of フローを使用して、Microsoft Graph で使用できるトークンに交換します。 完全に秘密のない方法でこれを行います。

⚠️ 重要:実験実装

【重要】 これは実験的な実装であり、生産シナリオでは使用しないでください。 ツイート このサンプルでは、保護されたMCPサーバーをEntra IDで構築する方法を実証しています。OAuth 2.0 Dynamic Client登録とPKCEフローパターンを実装することで、Entra IDのネイティブサポートで現在のギャップを回避できます。 技術的な可能性を秘めながら、教育と証拠の目的のみを目的としています。 ツイート 生産のシナリオについては、事前登録済みのアプリケーションと標準のOAuthフローで確立された認証パターンを使用して検討してください。

使い方

  • ⚡ Azure 関数
  • 🕸️ API 管理
  • 絶対Bicep
  • 会員の Python
  • Mackerel 開発者 CLI

[!NOTE]

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

🤫 Authenticated Remote MCP Server

This sample shows how to deploy an Entra ID-protected MCP server on Azure.

The sample also uses an authorization pattern where the client acquires a token for the MCP server first, and then uses on-behalf-of flow to exchange it for a token that can be used with Microsoft Graph. It does all this in an entirely secretless manner too.

⚠️ Important: Experimental Implementation

[!IMPORTANT] This is an experimental implementation and should NOT be used in production scenarios.

This sample demonstrates how to build a protected MCP server with Entra ID by implementing OAuth 2.0 Dynamic Client Registration and PKCE flow patterns that work around current gaps in Entra ID’s native support for these standards. While it showcases the technical possibilities, it’s intended for educational and proof-of-concept purposes only.

For production scenarios, consider using established authentication patterns with pre-registered applications and standard OAuth flows.

What it uses

[!NOTE] You can use the Model Context Protocol Inspector or Visual Studio Code to test this MCP server.

How the Authorization Flow Works

This implementation uses a sophisticated OAuth 2.0 flow with PKCE (Proof Key for Code Exchange) to securely authenticate MCP clients. Here’s how it all fits together:

sequenceDiagram
    participant Client as MCP Client
    participant Browser as User's Browser
    participant APIM as API Management
    participant Entra as Entra ID
    participant Function as Azure Function
    participant Graph as Microsoft Graph

    Note over Client,Graph: 1. Discovery & Registration
    Client->>APIM: GET /.well-known/oauth-authorization-server
    APIM->>Client: OAuth metadata (authorization_endpoint, token_endpoint, etc.)
    
    Client->>APIM: POST /register (Dynamic Client Registration)
    Note over APIM: Store client info in CosmosDBGenerate unique client_id
    APIM->>Client: Client credentials (client_id, no secret)

    Note over Client,Graph: 2. Authorization with PKCE
    Note over Client: Generate code_verifier & code_challenge
    Client->>Browser: Open authorization URL with PKCE params
    Browser->>APIM: GET /authorize?client_id=...&code_challenge=...
GitHub で README 全文を見る

インストール

npx @modelcontextprotocol/[email protected]
MCP 初心者?mcpskill.org のガイドから始めましょう →