Repository navigation
Add the MCP tool-call details type - #7283
Merged
Merged
Conversation
An access token redeemed from an ID-JAG should be able to serve only the
one MCP call an authorizer approved ("Authorization server: narrow a
JWT-bearer access token to one MCP call with authorization_details"
(#7061)). That needs an authorization_details type that describes the
call, shared by the authorization server and the vMCP that enforces it.
pkg/mcp/toolcalldetails defines https://toolhive.dev/mcp_tool_call: a
tool call (server, tool, arguments_sha256 as 64 lowercase hex,
operation_id) or a list call (server and one of tools/list,
prompts/list, resources/list, resources/templates/list). Register adds
it for token exchange, where AS-1 is meant to sign it into an ID-JAG,
and for JWT-bearer, where AS-2 is meant to read it from the signed
claim. The hook accepts
exactly one entry of its type and grants it unchanged; refusals are
invalid_authorization_details with single_entry_required,
malformed_entry, invalid_arguments_hash or invalid_method. On token
exchange it also refuses unless requested_token_type is the ID-JAG type
(invalid_request, id_jag_required), because a plain exchange would echo
the entry while the issued token carries nothing.
ParseEntry exposes the same shape check as an Entry value, so the vMCP
can parse a token's claim with one definition. It scans the object
itself and refuses repeated members, non-string values, trailing data,
invalid UTF-8 and any value holding U+FFFD, so the decoded value stays
one-to-one with the signed bytes instead of relying on the caller
having run Registry.Parse first.
It is safe to release on its own. Nothing registers the type by
default, and when an embedder does, no token is narrowed: the ID-JAG
token-exchange request still refuses the authorization_details
parameter, JWT-bearer redemption never consults the registry, an
access-token exchange is refused with id_jag_required, and refresh-token
exchange refuses the entry as an unknown type. The package depends only on authorizationdetails and
oauthproto, so the vMCP can import it without waiting on the
authorization-server changes.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7283 +/- ##
=======================================
Coverage 81.86% 81.87%
=======================================
Files 915 916 +1
Lines 92868 92935 +67
=======================================
+ Hits 76029 76092 +63
- Misses 16834 16838 +4
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jhrozek
previously approved these changes
Nov 24, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
LGTM, the type and the hook look right to me and I agree this is safe to land on its own. I left three small doc comments inline. None of them block this, they're fine as follow-ups, but it would be good to sort out the first two before the vMCP enforcement work ("vMCP: accept an access token for the one call its authorization_details names, once") starts coding against this doc.
Codespell read the JSON escape in "server" as the word "ser". Escape the first letter instead; the test still checks that an escaped member name decodes to the same name. Add rows for a member name that is not a string, an object without its closing brace, and an object closed by a bracket, which cover the two decoder error returns that had no test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Say what each member means so the vMCP and its clients implement the same
match: server is the ID of the backend the call is routed to, and tool is
params.name exactly as sent, including any backend prefix. A list call
lists only that backend's items. Fix the example to use the routed name.
The argument hash uses {} when arguments are absent or null, as agreed
for the vMCP check. Reword the token-exchange comment and the Register
doc so they don't suggest the ID-JAG path reads the entry today.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
jhrozek
approved these changes
Nov 24, 2026
4 tasks done
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
authorization_detailstype that describes the call. This PR adds that type, and nothing else, so the vMCP enforcement work can import it without waiting on the authorization-server changes.pkg/mcp/toolcalldetails, which depends only onpkg/authserver/authorizationdetailsandpkg/oauthproto.Typeishttps://toolhive.dev/mcp_tool_call. An entry is a tool call (server,tool,arguments_sha256as 64 lowercase hex characters,operation_id, all non-empty strings) or a list call (server,methodintools/list,prompts/list,resources/list,resources/templates/list). No other members, and the two shapes are never mixed.Registeradds the type for RFC 8693 token exchange and RFC 7523 JWT-bearer. The hook accepts exactly one entry of its type and grants it unchanged.invalid_authorization_detailswith one ofsingle_entry_required,malformed_entry,invalid_arguments_hash,invalid_method. On a token exchange that reaches the hook without requesting an ID-JAG, the refusal isinvalid_requestwithid_jag_required.EntryandParseEntryexpose the same shape check, so the vMCP enforcement in "vMCP: accept an access token for the one call its authorization_details names, once" (vMCP: accept an access token for the one call its authorization_details names, once #7062) can parse the token claim with this one definition.ParseEntryscans the object itself and refuses repeated members, non-string values, trailing data, invalid UTF-8 and any value containing U+FFFD. It does not rely on the caller having runRegistry.Parsefirst.arguments_sha256(RFC 8785 serialization ofparams.arguments, or of{}when absent), states the intended AS-1 / AS-2 use, and states that the authorization-server handlers do not read the entry yet.docs/arch/17-token-exchange-delegation.md.Part of #7061.
Safe to merge and release on its own. Nothing registers the type by default, and even when an embedder registers it, no token is narrowed or appears narrowed:
authorization_detailsparameter (checkIDJAGExtraParameters), before the registry is consulted;Registry.Parsecallers use the token-exchange grant), so the JWT-bearer registration is inert;requested_token_type) that sends the entry is refused by the hook withid_jag_required;invalid_authorization_details) before any hook runs.The AS-1 signing and AS-2 claim changes build on this package later; each updates the package doc's "do not read it yet" paragraph when it lands.
Type of change
Test plan
task test): passtask lint-fix): 0 issuesgo test -race ./pkg/mcp/toolcalldetails/... ./pkg/authserver/...andgolangci-lint run ./pkg/mcp/toolcalldetails/...: pass, 0 issues.New tests:
authorizationdetails.Registry: tool and list calls on JWT-bearer (emptyRequestedTokenType) and on ID-JAG token exchange;id_jag_requiredfor an access-token, a refresh-token and an emptyrequested_token_type(the refresh-token row pins the hook's rule; on main the refresh-token handler refuses the entry earlier);single_entry_requiredon both grants; unknown, missing, empty, non-string and mixed members; bad hashes; a method outside the set;ParseEntryon its own: all four list methods and near misses; non-hex and wrong-length hashes; a missingserverin either shape; other or missingtype; repeated members, including an escaped repeat; a member in a different letter case; number, null and object values; trailing data; a non-object; invalid JSON; invalid UTF-8; an unpaired surrogate escape and a literal U+FFFD; empty input; and accepted escapes and whitespace.Changes
pkg/mcp/toolcalldetails/toolcalldetails.goType, reasons,Entry,ParseEntry,Registerand its hookpkg/mcp/toolcalldetails/toolcalldetails_test.godocs/arch/17-token-exchange-delegation.mdDoes this introduce a user-facing change?
No. Nothing registers the type by default. An embedder that registers it sees one difference: a non-ID-JAG token exchange that sends the entry was refused as an unregistered type (
invalid_authorization_details) and is now refused withinvalid_request/id_jag_required. ID-JAG requests and JWT-bearer redemption behave as before.Special notes for reviewers
Confirmed in the issue discussion (#7061 comment, #7062 comment):
requested_token_typeisurn:ietf:params:oauth:token-type:id-jag, and otherwise refuses withid_jag_required(codeinvalid_request, sincerequested_token_typeis the related parameter at fault). Without this rule a plain RFC 8693 exchange would accept and echo the entry while the token it issues carries nothing, so the client would believe it holds a narrowed token.single_entry_requiredandmalformed_entryapply permcp_tool_calltype. The hook sees only entries of its own type (Pending.Grantgroups by type); entries of other registered types are left to their own hooks.Other notes:
ParseEntryrefuses any value containing U+FFFD.encoding/jsondecodes an unpaired surrogate escape such as\ud800to U+FFFD, so without the check two different signed values could compare equal after decoding.Entryhas no JSON tags on purpose. Decoding withjson.Unmarshalwould skip the shape check (and keep the last of two repeated members), so the only way in isParseEntry.arguments_sha256or compares it with real arguments; the vMCP enforces the call (vMCP: accept an access token for the one call its authorization_details names, once #7062).ParseEntryhas its own small token scanner rather than usingpkg/mcp'sDecodeJSONObjectMembers, to keep the package's dependencies toauthorizationdetailsandoauthproto.🤖 Generated with Claude Code