EMA leg 2 strips the trailing slash from the authorization server URL, so audience no longer equals the issuer
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 76/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- typescript
- Domaine
- authentication, backend-api-design
Piste de recherche
Commencez dans core/auth/ema/emaFlow.ts, à la construction de l’audience à la ligne 82, puis suivez la façon dont l’URL du serveur d’autorisation est découverte et transmise à EMA leg 2. Vérifiez s’il existe déjà des tests couvrant l’échange de jetons et ajoutez ou mettez à jour un cas où l’issuer se termine par /. Le travail est terminé lorsque l’audience envoyée à l’IdP correspond exactement à l’issuer annoncé, barre oblique finale comprise.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Which version line?
v2 — current (@modelcontextprotocol/inspector@latest)
Which client?
Web
Inspector version
2.17.0
Node version
v24.22.3
Operating system (and browser, for the web client)
macOS 26.7.3, Chrome 158
Transport
Streamable HTTP
MCP server under inspection
- Server: a small xmcp server (name "xmcp server", version 0.1.0) over Streamable HTTP at http://localhost:3001/mcp, protected by Auth0 as the authorization server. Source: https://github.com/auth0-samples/mcp-workshop (branch step-5-cross-app-access). It only exposes tools.
- Protocol era: legacy (as shown in the Inspector's Server Implementation panel). Protocol 2025-11-25, session-based.
- OAuth: yes. Enterprise-managed authorization (EMA) is on. The IdP is Okta, and the resource authorization server is Auth0 (issuer https://tenant.eu.auth0.com/, with a trailing slash). The server's protected resource metadata lists that issuer.
Steps to reproduce
- Use an IdP with XAA (Okta) and a resource AS whose issuer ends with / (Auth0).
- Register the resource AS issuer with the slash at the IdP.
- In the Inspector, enable enterprise-managed authorization and connect.
- Leg 2 fails with
invalid_target. The network export showsaudiencewithout the slash.
Expected behavior
audience equals the authorization server's issuer exactly as the metadata advertises it. RFC 8414 treats the issuer as an exact string, and the ID-JAG's aud must match the resource AS's issuer, so https://x/ and https://x are different values.
Actual behavior
In enterprise-managed authorization (EMA) leg 2, the Inspector sends the IdP token exchange an audience built like this:
// core/auth/ema/emaFlow.ts, line 82
const audience = ctx.resourceAsUrl.href.replace(/\/$/, "");
If the resource authorization server's issuer ends with /, the slash is dropped. Auth0 issuers always end with / (for example https://tenant.eu.auth0.com/), and the protected resource metadata lists it that way:
{
"resource": "http://localhost:3001/mcp",
"authorization_servers": ["https://tenant.eu.auth0.com/"]
}
The request the Inspector sent to Okta's /oauth2/v1/token (secrets removed):
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
requested_token_type=urn:ietf:params:oauth:token-type:id-jag
audience=https://tenant.eu.auth0.com <- slash removed
resource=http://localhost:3001/mcp
subject_token_type=urn:ietf:params:oauth:token-type:id_token
scope=tool:...
Okta answers 400 invalid_target ("The token request contains an invalid target."), because the registered issuer is https://tenant.eu.auth0.com/.
Logs, errors, or screenshots
[
{
"request": "GET http://localhost:3001/.well-known/oauth-protected-resource",
"status": 200,
"response": {
"resource": "http://localhost:3001/mcp",
"authorization_servers": ["https://tenant.eu.auth0.com/"],
"bearer_methods_supported": ["header"],
"scopes_supported": ["openid", "profile", "email"]
}
},
{
"request": "POST https://idp.example.com/oauth2/v1/token",
"contentType": "application/x-www-form-urlencoded",
"body": {
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
"requested_token_type": "urn:ietf:params:oauth:token-type:id-jag",
"audience": "https://tenant.eu.auth0.com",
"resource": "http://localhost:3001/mcp",
"subject_token": "",
"subject_token_type": "urn:ietf:params:oauth:token-type:id_token",
"client_id": "",
"client_secret": "",
"scope": "tool:whoami tool:order_pizza"
},
"status": 400,
"response": {
"error": "invalid_target",
"error_description": "The token request contains an invalid target."
}
}
]
The web UI shows the following error:
Failed to connect to "xmcp-demo"
EMA legs 2–3 (resource token mint): EMA leg 2 (IdP token exchange for ID-JAG): Token exchange failed: invalid_target - The token request contains an invalid target.
Already prototyped a fix?
Send ctx.resourceAsUrl.href unchanged, or better, the issuer value from the discovered authorization server metadata. If a normalization was added for a particular server, make it opt-in per server.
Before you submit
- I searched existing issues and this is not a duplicate.
- This is not a security vulnerability report (those go through the private advisory process).
- Langage dominant
- TypeScript
- Étoiles
- 11.3k
- Forks
- 1.6k
- Merge moyen
- 2 h 31 min
- PR mergées (30 j)
- 118
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de modelcontextprotocol/inspector
-
bug cli v2
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
modelcontextprotocol/inspector#3095 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
documentation v2
Difficulté 2/5 1-3 heures Accessibilité débutants 58/100
modelcontextprotocol/inspector#3008 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
chore v2
Difficulté 2/5 1-3 heures Accessibilité débutants 30/100
modelcontextprotocol/inspector#3000 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement v2
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 12/100
modelcontextprotocol/inspector#2981 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
blocked chore v2
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
modelcontextprotocol/inspector#2548 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de modelcontextprotocol/inspector
Issues similaires
-
[typescript] BasicAuth.fromAuthorizationHeader accepts headers without the Basic scheme prefixOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement severity:low
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
Battle-Cattle/BCUK-Bot-4#1252 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
onyx-dot-app/onyx#18730 ·
Les mainteneurs répondent en général sous 1 jour
-
[Integration]: CoinStats APIOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ava-labs/builders-hub#4924 ·
Les mainteneurs répondent en général sous 1 jour