Skip to content

vMCP: give call-binding refusals a machine-readable reason #7362

Done

Description

@rdimitrov

Problem

When the vMCP refuses a call-bound access token, the reason is given only in human-readable text:

  • 401 reasons (for example token_reused, token_expired) go through Challenge().WriteInvalidToken, with error="invalid_token" and error_description="the access token is not accepted (token_reused)" (pkg/vmcp/server/call_binding.go, refuse).
  • 403 reasons go into the JSON-RPC error message: "Forbidden: the access token does not permit this request (method_mismatch)".

A client that has to act differently on a specific reason must match that text. One client needs to: on token_reused, it must not retry the call with a fresh token. If a stolen token had already started the call, a retry would run it a second time. So it reports the outcome as unknown instead. Today that decision depends on the wording of error_description, which can change without notice.

Proposal

Expose the refusal reason (callbinding.Reason*) as a stable, documented field that clients can rely on, alongside the current text, for example:

  • an extra auth-param on the WWW-Authenticate challenge for the 401s (RFC 6750 section 3 allows additional auth-params, while error stays invalid_token), and
  • a data.reason field on the JSON-RPC error for the 403s.

The text in error_description and the message stays as it is, so existing clients keep working.

Done when

  • Every call-binding refusal carries its reason in a machine-readable field, documented with the list of reason values in docs/authz.md.
  • Tests pin the field for at least token_reused, token_expired, no_open_call and method_mismatch.

Activity

  1. added
    needs-triage
    on Nov 27, 2026
  2. rdimitrov commented on Nov 27, 2026

    @rdimitrov
    MemberAuthor

    Timing: this is not needed while Mecatl embeds the vMCP, and becomes required before Mecatl can call a vMCP it does not embed (stacklok/mecatl#2812).

    • Now. Mecatl runs the vMCP in its own process, so a ToolHive version reaches it only through a module bump. A test against the real vMCP (feat(identitybroker): bind each gateway token to its call mecatl#3008) spends a token, replays it, and requires the outcome to be reported as unknown. A rewording of error_description would fail that test when ToolHive is bumped, rather than turn the refusal into a silent retry.
    • With an external gateway. Mecatl would talk to whatever vMCP version is deployed, and the test above no longer covers it. The client then needs the reason as a field rather than text, so that token_reused is never retried.

    When this lands, the Mecatl side reads the field first and keeps the text match for older vMCPs.

  3. self-assigned this
    on Nov 28, 2026
  4. added a commit that references this issue on Nov 28, 2026
    b0f9de2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions