Skip to content

vMCP: record the call-bound token's operation ID and jti, and the IDs a client reports #6979

Open

Description

@jhrozek

Part of #6886 (the gateway side is in the scope of #6406). Related: #3919 (audit logging in the authorization server).

Problem: a client that mediates tool calls, such as an agent harness's broker, records each call as an operation with one or more attempts. The vMCP's mcp_tool_call audit events cannot be joined exactly to the client's records. A join by user, tool, and time picks the wrong record when one agent calls the same tool twice in parallel.

Since "Authorization server: narrow a JWT-bearer access token to one MCP call with authorization_details" (#7061) and "vMCP: accept an access token for the one call its authorization_details names, once" (#7062), the vMCP holds two verified identifiers for each call:

  • the operation_id in the token's https://toolhive.dev/mcp_tool_call entry. The authorization server signed it, and the vMCP validates the token before it admits the call;
  • the token's jti. A call-bound token starts one call, so its jti names that attempt.

The audit already reads the first one, but only for a request admitted after its token expired (stampAdmittedAfterExpiry in pkg/audit/auditor.go, key operation_id). No event records the jti.

Change:

  • Verified values. For every request whose validated token carries a call entry, record the entry's operation_id in Metadata.Extra["operation_id"] (the existing key), and the token's jti in a new Metadata.Extra key, for example token_jti. Record the token's iss too if it is not already on the event. Do this for allowed calls, denials, and binding refusals. A listing token has no operation_id, so record only the jti.
  • Reported values. Read the operation and attempt identifiers from the MCP request's _meta, under configurable keys, and the run identifier from trace headers. Record them under separate keys marked as reported, for example reported_operation_id and reported_attempt_id. Never write a reported value into a verified key. Limit their length and character set, and drop a malformed value with a log line.
  • Record none of these as subjects. Subjects say who acted; these say which call.
  • Never use any of these values for an authorization or policy decision in this change. The call binding already checks the token's entry.

Acceptance:

  • a call with a call-bound token yields an event with the entry's operation_id and the token's jti, also when the call is denied or refused by the binding;
  • with two parallel calls to the same tool by the same client, each event carries its own jti and operation_id;
  • a _meta value that differs from the token's operation_id is recorded under the reported key, and the verified key keeps the token's value;
  • a malformed or oversized _meta value is dropped and does not fail the request;
  • no token value and no other claim reach the event.

What Mecatl removes when this lands: Mecatl embeds the vMCP and, as a stopgap (stacklok/mecatl#3023), sets AuditSubjectEnricher to add gateway_token_jti and operation_id as subjects on each event, read from the validated token. When this lands, Mecatl removes that enricher and joins on the new fields instead.

Activity

  1. added
    needs-triage
    on Oct 28, 2026
  2. changed the title [-]Record the operation and attempt IDs a client reports, at the authorization server and the vMCP[/-] [+]Record the operation and attempt IDs a client reports, at the vMCP[/+] on Nov 24, 2026
  3. removed
    needs-triage
    on Nov 24, 2026
  4. changed the title [-]Record the operation and attempt IDs a client reports, at the vMCP[/-] [+]vMCP: record the call-bound token's operation ID and jti, and the IDs a client reports[/+] on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions