EMA leg 3: support private_key_jwt client authentication at the resource authorization server
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 58/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- api, authentication
调研方向
Start with core/auth/ema/wire.ts and core/auth/ema/tokenEndpoint.ts, then review the existing createPrivateKeyJwtAuth SDK helper and the prototype details in the issue. Trace how per-server oauth.clientSecret is stored, redacted, and edited in Server Settings, and check the existing EMA and keychain tests. Done when leg 3 can use a private key to send a token-endpoint-audience client assertion without sending a configured secret, with key storage and UI covered.
由索引模型根据 Issue 内容生成。
描述
Which client?
All / shared core
The problem
When a server uses enterprise-managed authorization, leg 3 (redeeming the ID-JAG at the resource authorization server with the jwt-bearer grant) can only authenticate the client with client_secret_post or, since #2725, none. redeemIdJagForAccessToken in core/auth/ema/wire.ts builds the client information from resourceClientSecret alone, and applyClientAuth in core/auth/ema/tokenEndpoint.ts handles only client_secret_basic and client_secret_post.
An ID-JAG is a bearer assertion, so a resource AS can reasonably require a confidential client at leg 3, and some require one that proves possession of a key (private_key_jwt). Against such a server the Inspector cannot complete leg 3 at all, even though leg 2 succeeds.
To reproduce:
- Register a client at a resource AS that advertises
private_key_jwtintoken_endpoint_auth_methods_supportedand requires a key for thejwt-bearergrant. - Configure the IdP in Client Settings → Enterprise-Managed Authorization, connected to that resource AS for the same client id.
- In the server's settings, turn on enterprise-managed authorization and set the Resource AS Client ID.
- Connect. Leg 2 returns an ID-JAG. Leg 3 fails with
invalid_client, because the request carries either no client authentication or a secret the server does not accept.
Solution you have in mind (optional)
A third choice next to the client secret: a private key. When set, leg 3 sends client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer and a client_assertion signed with it, with iss = sub = the client id and aud = the token endpoint (RFC 7523 §2.2, §3), and no client_secret.
The SDK already ships createPrivateKeyJwtAuth, so core/ would take no new dependency. Two details worth deciding deliberately:
- Pass
audexplicitly as the token endpoint. The helper defaultsaudto the AS metadataissuer. RFC 7523 allows that, but some servers accept only the token endpoint URL there; the token endpoint is the value every server accepts. kid.createPrivateKeyJwtAuthhas no option to put akidin the assertion header. A server that tries each registered key works without one; a server that selects the key bykidwould not. An optionalkidin the SDK helper would close that gap.
Alternatives or workarounds you have tried
- Registering a second, secret-based client at the resource AS just for the Inspector. That is only possible where the AS still allows secrets for this grant, and it tests a different client from the one real agents use.
- Minting the resource token outside the Inspector (a separate script doing legs 1–3 with the key) and pasting it as a static
Authorization: Bearerheader. That works, but it skips the Inspector's own discovery, resource and scope handling, which is what we wanted to exercise.
Already built it locally?
Yes, as a prototype in a fork, and tested end to end against a real resource AS: IdP sign-in, ID-JAG from the IdP, leg 3 authenticated with private_key_jwt, then tools listed. The design, so it can be reproduced through your workflow:
- A new
core/auth/ema/clientAssertion.ts. It accepts a PKCS#8 PEM or a private JWK and infers the algorithm from the key: a JWK's ownalgwins; otherwise ES256, ES384, ES512, RS256 and EdDSA are tried in order. It returns the two form parameters. A SEC1 or PKCS#1 PEM is rejected with a message pointing toopenssl pkcs8 -topk8 -nocrypt, and a public JWK is rejected as having no private part. redeemIdJagForAccessTokentakes an optionalresourceClientPrivateKey. The order is key, then secret, then none. With a key set, no secret is sent, even if one is configured.- The key is a per-server
oauth.clientPrivateKey, handled exactly likeclientSecret: it is kept in the OS keychain (new fieldoauth-client-private-key), never written tomcp.json, kept on a config-only save, and shown as[redacted]byservers list. - Server Settings → Authorization gets a "Resource AS Client Private Key" input, shown only while enterprise-managed authorization is on, since it is used only at leg 3. A pasted PEM loses its line breaks in a single-line input; that is harmless, because
joseignores whitespace in PEM bodies. - Tests: unit tests for the new module (keys generated per run with
jose, the assertion checked withjwtVerify), a leg-3 test asserting a valid assertion is sent and the configured secret is not, keychain lift/merge round-trip tests, form tests, and the redaction case inservers-list.test.ts.
It was prototyped with an AI coding agent from a short instruction: "add private_key_jwt client authentication to EMA leg 3: an optional per-server key, the assertion's aud set to the token endpoint, sent as client_assertion + client_assertion_type". Happy to share screenshots of the settings field and the successful connection.
Before you submit
- I searched existing issues and this is not a duplicate.
- This is a request for the Inspector itself, not for the MCP specification or an SDK.
- 主要语言
- TypeScript
- 星标
- 11.3k
- 派生
- 1.6k
- 平均合并
- 2 小时 28 分钟
- 30 天内合并 PR
- 111
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/inspector 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
modelcontextprotocol/inspector#3073 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/inspector#3072 ·
维护者通常 1 天内回复
-
CLI/mcpdo: a timeout above 2147483647 ms fires after 1 ms, and the error says to raise it further未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/inspector#3071 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/inspector#3069 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/inspector#3067 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/inspector 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
danielmiessler/LifeOS#3028 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
-
iOS: last line of a long UITextView text is sometimes not drawn (frame a fraction of a point short)未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 90/100
Koenkk/zigbee2mqtt#33855 ·
维护者通常 1 天内回复