Skip to main content

Accept workload assertions with the JWT-bearer grant

Use the RFC 7523 JWT-bearer grant to let a trusted workload exchange a signed assertion for a ToolHive token through a Virtual MCP Server (vMCP). The workload does not need a ToolHive client registration or shared secret; it proves who it is with whatever identity its platform already issued it (a cloud IAM role, a Kubernetes-native workload identity, or a service identity from your IdP).

info

The inboundGrants.jwtBearer.issuerPolicies field covered here is also available on a plain MCPServer through MCPExternalAuthConfig's embeddedAuthServer block, using the same configuration structure shown below under authServerConfig. For the MCPServer field reference, see Set up the embedded authorization server in Kubernetes.

If you're choosing between mechanisms, see the comparison table in Choose a way to get a token. The JWT-bearer grant answers "how does a workload with no registered client get a token at all?". RFC 8693 delegation answers a different question: "who is this agent acting for?"

Configure a trusted issuer​

To accept an assertion, ToolHive needs an inboundGrants.jwtBearer.issuerPolicies entry naming the workload's subject and the resource it may request. These fragments nest under spec.authServerConfig. What the entry looks like depends on the identity provider:

Okta's Custom Authorization Server lets you set its audiences field to an arbitrary caller-chosen string, so you can register it as the exact ToolHive token endpoint the workload's assertion will be presented to:

VirtualMCPServer: jwtBearer issuer policy
trustedIssuers:
- name: okta-issuer
issuerUrl: 'https://<org>.okta.com/oauth2/<AUTH_SERVER_ID>'
jwksUrl: 'https://<org>.okta.com/oauth2/<AUTH_SERVER_ID>/v1/keys'
inboundGrants:
jwtBearer:
issuerPolicies:
- issuerRef: okta-issuer
maxAssertionAge: 5m
subjectBindings:
- subject: '<OKTA_SERVICE_APP_CLIENT_ID>'
allowedResources:
- https://vmcp.example.com/mcp-resource

expectedAudience, actorClaim, actorMatcher, and allowMayAct (all under inboundGrants.tokenExchange.issuerPolicies) are delegation-specific and unrelated to the JWT-bearer grant; an issuer used only for inboundGrants.jwtBearer needs none of them.

A JWT-bearer-only configuration doesn't need upstreamProviders: when you omit it, the authorization server runs in token-only mode and issues tokens only through the grants you configure. A VirtualMCPServer with no upstreamProviders can't also set incomingAuth.authzConfig.

Request a token​

Once a trusted issuer is configured, the workload sends its assertion straight to /oauth/token; possession of the assertion is the only credential ToolHive checks:

POST /oauth/token
curl -s -X POST https://vmcp.example.com/oauth/token \
-d "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer" \
-d "assertion=<SIGNED_ASSERTION>" \
-d "resource=https://vmcp.example.com/mcp-resource"

ToolHive mints a token for a synthetic client derived deterministically from the assertion's issuer and subject. There's no delegation and nothing to pre-register.

ToolHive refuses an assertion that carries a cnf (confirmation) claim, with any value. A cnf claim means the issuer bound the assertion to a key, and ToolHive can't verify that proof of possession, so it won't redeem the assertion as a plain bearer credential.

Limit which assertion forms an issuer accepts​

The JWT-bearer grant accepts two forms of signed assertion from a trusted issuer: a plain RFC 7523 assertion, as shown above, and an Identity Assertion JWT Authorization Grant (ID-JAG), the assertion an IdP mints for cross-application access. By default, an issuer policy accepts both, so trusting an issuer for one form also trusts it for the other.

Set acceptedAssertionTypes on the issuer policy to limit it to one form:

VirtualMCPServer: issuer policy limited to ID-JAG
inboundGrants:
jwtBearer:
issuerPolicies:
- issuerRef: okta-issuer
acceptedAssertionTypes: ['id_jag']
subjectBindings:
- subject: '<USER_SUBJECT>'
allowedResources:
- https://vmcp.example.com/mcp-resource
ValueEffect
omittedToolHive accepts both plain assertions and ID-JAGs from the issuer.
['jwt_bearer']ToolHive accepts only plain assertions from the issuer.
['id_jag']ToolHive accepts only ID-JAGs from the issuer.
['jwt_bearer', 'id_jag']Same as omitting the field.

An assertion of a form the issuer doesn't accept gets invalid_grant with the same "issuer is not enabled for this grant" hint as an unknown issuer.

Use ['id_jag'] for an issuer that acts as the IdP for cross-application access. The plain grant needs no client credentials, so without this restriction any other JWT that IdP signs for a bound subject could be redeemed on it. Subject bindings apply to both forms: a binding you add for an ID-JAG's subject also authorizes a plain assertion for that subject whenever jwt_bearer is accepted.

Redeeming an ID-JAG has two requirements that the plain grant doesn't:

  • The redeeming client must authenticate as a confidential client (for example, with client_secret_basic, client_secret_post, or private_key_jwt). A public client, or a request with no client credentials, gets HTTP 401 invalid_client with the reason client_authentication_required, and the ID-JAG stays unused so the right client can still redeem it.
  • The ID-JAG specification sets an ID-JAG's aud to this authorization server's issuer identifier. With acceptedAudiences omitted, ToolHive accepts either the issuer or the token endpoint URL as an ID-JAG's aud. When you list id_jag explicitly, the server fails to start if acceptedAudiences is set but doesn't include the issuer, or if acceptedAudiences is omitted and the issuer is also listed as an allowed resource.

Next steps​

Troubleshooting​

Two things vary by issuer and are worth checking first if an exchange fails: whether the assertion carries a jti at all (Entra's client_credentials tokens and plain SPIRE JWT-SVIDs never include one, so ToolHive falls back to hashing the raw assertion for replay protection instead), and whether the assertion's aud needs an acceptedAudiences entry to match, per the tabs above.

When an assertion fails a validation rule, ToolHive returns invalid_grant with an error_description that starts with the reason code invalid_assertion, followed by a hint. A client can read the reason code to decide how to respond without parsing the hint.

ErrorLikely cause
invalid_grant: "invalid_assertion: The JWT bearer assertion issuer is not enabled for this grant."The assertion's iss doesn't match a trustedIssuers entry with an inboundGrants.jwtBearer.issuerPolicies entry configured, or the issuer policy's acceptedAssertionTypes excludes this assertion form.
invalid_grant: "invalid_assertion: The JWT bearer assertion must not carry a 'cnf' claim."The assertion is key-bound with a cnf claim. Ask the issuer for an assertion without cnf.
HTTP 401 invalid_client: "client_authentication_required: The ID-JAG grant requires client authentication."An ID-JAG was presented by a public client or without client credentials. Register the redeeming client as confidential and authenticate it on the request.
invalid_grant: "The JWT bearer assertion subject is not configured for this grant."The assertion's sub has no matching entry in issuerPolicies[].subjectBindings.
invalid_targetThe resource parameter isn't in the matched subject binding's allowedResources.
invalid_grant: "invalid_assertion: The JWT bearer assertion has already been used."The assertion's replay key (its jti, or a hash of the assertion when jti is absent) was already consumed.
invalid_grant: "invalid_assertion: The JWT bearer assertion exceeds the configured maximum age."The assertion's issued lifetime (exp minus iat) is longer than the issuer policy's maxAssertionAge. Request a shorter-lived assertion, or raise maxAssertionAge.
HTTP 503 temporarily_unavailable: "issuer_unavailable"ToolHive couldn't fetch the issuer's signing keys, so it never evaluated the assertion. Check that the issuer's JWKS endpoint is reachable from the authorization server, then retry the request.