[v2] Multi-tenant Entra ID metadata fails the issuer check: issuer is the literal {tenantid} template

オープン
#3,207 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
活発
技術スタック
typescript

調査の方向性

Start with the authorization server metadata discovery and issuer validation code, then read the documentation for skipIssuerMetadataValidation and the related tests. The issue presents several possible outcomes and asks maintainers to decide whether to document the existing escape hatch, improve the error, or add narrower validation behavior. Done means the chosen approach is agreed and implemented with appropriate tests and documentation.

索引モデルが issue の本文から書いたものです。

説明

v2
What happened?

OAuth discovery fails against a multi-tenant Microsoft Entra ID authority, so any MCP server whose protected-resource metadata names one (for example https://login.microsoftonline.com/organizations/v2.0) cannot be connected to with the default client settings.

Entra's multi-tenant metadata documents (/organizations/v2.0 and /common/v2.0) return the literal, unsubstituted template as issuer:

GET https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration
  "issuer": "https://login.microsoftonline.com/{tenantid}/v2.0"

The SDK's RFC 8414 §3.3 comparison then rejects it:

IssuerMismatchError (kind "metadata"): Issuer mismatch in authorization server metadata (RFC 8414 §3.3):
  expected "https://login.microsoftonline.com/organizations/v2.0",
  received "https://login.microsoftonline.com/{tenantid}/v2.0"

The check is correct: the document is non-conformant with RFC 8414 §3.3 / OIDC Discovery §4.3, and that is Entra's defect rather than the SDK's. It is still a widely deployed authorization server, and this was reported to the MCP Inspector by a user connecting to a Microsoft Fabric MCP endpoint (modelcontextprotocol/inspector#2983).

The existing escape hatch works — with skipIssuerValidation: true on discovery (or skipIssuerMetadataValidation: true on auth() / the transports) the document is accepted. The Inspector now exposes that as a per-server opt-in, default off (modelcontextprotocol/inspector#3020). The cost is that the opt-out turns the whole issuer comparison off for that server, which is a much broader relaxation than this one known shape needs.

What did you expect?

Raising this for a decision rather than asserting an answer. Options, roughly in order of how much they change:

  1. Nothing in code; document it. Name multi-tenant Entra in the skipIssuerMetadataValidation docs as the known case, so hosts know what the option is for.
  2. Point at the option from the error. Have the metadata-kind IssuerMismatchError message mention skipIssuerMetadataValidation, so each host does not have to add its own hint.
  3. A narrower tolerance than the full opt-out. For example an opt-in comparison hook (a caller-supplied predicate over expected/received issuer), or an opt-in that accepts only a received issuer equal to the expected URL with one path segment replaced by the literal {tenantid}. Either would let a host accept this shape without disabling the mix-up defense for everything else.

Entra's multi-tenant metadata does not advertise authorization_response_iss_parameter_supported, so the RFC 9207 authorization-response check is not involved.

Code to reproduce
import { discoverAuthorizationServerMetadata } from "@modelcontextprotocol/client";

// Throws IssuerMismatchError (kind "metadata")
await discoverAuthorizationServerMetadata(
  new URL("https://login.microsoftonline.com/organizations/v2.0"),
);

// Returns the metadata document
await discoverAuthorizationServerMetadata(
  new URL("https://login.microsoftonline.com/organizations/v2.0"),
  { skipIssuerValidation: true },
);
SDK version

@modelcontextprotocol/client 2.4.0

Area

Auth

主要言語
TypeScript
スター
13.8k
フォーク
2.5k
平均マージ
6日 23時間
マージ済み PR(30日)
2

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/typescript-sdk のほかの issue

modelcontextprotocol/typescript-sdk の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。