EMA leg 2 strips the trailing slash from the authorization server URL, so audience no longer equals the issuer
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
从 core/auth/ema/emaFlow.ts 第 82 行的 audience 构造处开始,然后追踪授权服务器 URL 是如何被发现并传入 EMA leg 2 的。检查是否已有涵盖令牌交换的测试,并添加或更新一个 issuer 以 / 结尾的用例。完成的标准是发送给 IdP 的 audience 与公布的 issuer 完全一致,包括末尾的斜杠。
由索引模型根据 Issue 内容生成。
描述
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).
- 主要语言
- TypeScript
- 星标
- 11.3k
- 派生
- 1.6k
- 平均合并
- 2 小时 31 分钟
- 30 天内合并 PR
- 118
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/inspector 的其他 Issue
-
bug cli v2
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/inspector#3095 · 2 条评论 ·
维护者通常 1 天内回复
-
documentation v2
难度 2/5 1-3 小时 新手友好度 58/100
modelcontextprotocol/inspector#3008 · 4 条评论 ·
维护者通常 1 天内回复
-
chore v2
难度 2/5 1-3 小时 新手友好度 30/100
modelcontextprotocol/inspector#3000 · 1 条评论 ·
维护者通常 1 天内回复
-
enhancement v2
难度 5/5 一周以上 新手友好度 12/100
modelcontextprotocol/inspector#2981 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
blocked chore v2
难度 4/5 3-5 天 新手友好度 48/100
modelcontextprotocol/inspector#2548 · 1 条评论 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/inspector 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
enhancement severity:low
难度 2/5 1-3 小时 新手友好度 74/100
Battle-Cattle/BCUK-Bot-4#1252 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
onyx-dot-app/onyx#18730 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
ava-labs/builders-hub#4924 ·
维护者通常 1 天内回复