EMA leg 3: support private_key_jwt client authentication at the resource authorization server

Đang mở
#2,989 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
58/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, authentication

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement v2
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:

  1. Register a client at a resource AS that advertises private_key_jwt in token_endpoint_auth_methods_supported and requires a key for the jwt-bearer grant.
  2. Configure the IdP in Client Settings → Enterprise-Managed Authorization, connected to that resource AS for the same client id.
  3. In the server's settings, turn on enterprise-managed authorization and set the Resource AS Client ID.
  4. 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 aud explicitly as the token endpoint. The helper defaults aud to the AS metadata issuer. RFC 7523 allows that, but some servers accept only the token endpoint URL there; the token endpoint is the value every server accepts.
  • kid. createPrivateKeyJwtAuth has no option to put a kid in the assertion header. A server that tries each registered key works without one; a server that selects the key by kid would not. An optional kid in 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: Bearer header. 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 own alg wins; 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 to openssl pkcs8 -topk8 -nocrypt, and a public JWK is rejected as having no private part.
  • redeemIdJagForAccessToken takes an optional resourceClientPrivateKey. 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 like clientSecret: it is kept in the OS keychain (new field oauth-client-private-key), never written to mcp.json, kept on a config-only save, and shown as [redacted] by servers 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 jose ignores whitespace in PEM bodies.
  • Tests: unit tests for the new module (keys generated per run with jose, the assertion checked with jwtVerify), 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 in servers-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.
Ngôn ngữ chính
TypeScript
Star
11.3k
Fork
1.6k
Merge trung bình
2 giờ 28 phút
Pull request đã merge (30 ngày)
111

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của modelcontextprotocol/inspector

Tất cả issue của modelcontextprotocol/inspector

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.