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

Ouverte
#2,989 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
58/100
Type d'issue
Fonctionnalité
Clarté
Clairement spécifiée
Activité
Active
Stack technique
typescript
Domaine
api, authentication

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.
Langage dominant
TypeScript
Étoiles
11.3k
Forks
1.6k
Merge moyen
2 h 28 min
PR mergées (30 j)
111

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de modelcontextprotocol/inspector

Toutes les issues de modelcontextprotocol/inspector

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.