Documentation
¶
Overview ¶
Package toolcalldetails defines the RFC 9396 authorization_details type that narrows an access token to one MCP call. An entry is either a tool call
{"type": "https://toolhive.dev/mcp_tool_call", "server": "github",
"tool": "github_pull_request_read", "arguments_sha256": "<64 lowercase hex>",
"operation_id": "op-1"}
or a list call
{"type": "https://toolhive.dev/mcp_tool_call", "server": "github",
"method": "tools/list"}
server is the ID of the vMCP backend the call is routed to, not the vMCP the token is presented to. tool is the request's params.name exactly as the client sends it, which is the name the vMCP routes by: with the default prefix strategy that includes the backend prefix, as in the example. A tool call matches only when params.name equals tool and the vMCP routes it to the backend named by server. For a list call, server names the one backend whose items the call may list: a list request names no server, so the vMCP answers it with only that backend's items.
arguments_sha256 is the lowercase hex SHA-256 of the RFC 8785 (JSON Canonicalization Scheme) serialization of params.arguments, or of {} when params.arguments is absent or null. A request carries exactly one entry of this type, with no members other than those shown above. The hook sees only its own type's entries, so it cannot refuse entries of other registered types sent alongside.
The intended use is the ID-JAG flow. The authorization server that issues an ID-JAG (AS-1) accepts the entry on the RFC 8693 token-exchange request for an ID-JAG and signs it into the ID-JAG's authorization_details claim. The authorization server that redeems the ID-JAG with the RFC 7523 JWT-bearer grant (AS-2) takes the entry only from that signed claim, never from a redemption parameter or from a JWT-bearer assertion that is not an ID-JAG, and copies the signed bytes into the access token.
Registering the type only makes it known to a server's registry; each handler decides whether and where it reads the entry. In pkg/authserver, both sides are implemented: a token exchange for an ID-JAG signs the granted entry into the ID-JAG in encoding/json form (the request bytes compacted, with <, >, &, U+2028 and U+2029 escaped), and ID-JAG redemption processes the signed claim and copies a granted entry's signed bytes into the access token. Register the type on both servers. A token exchange that reaches the hook without requesting an ID-JAG is refused with ReasonIDJAGRequired.
No authorization server computes the arguments hash or compares it with real arguments: the receiver of the access token enforces the call. ParseEntry gives the receiver the same shape check the hook applies.
Nothing registers the type by default. An embedder adds it with Register to the types it passes to authorizationdetails.New.
Index ¶
Constants ¶
const ( // ReasonSingleEntry: the request held more than one entry of this type. ReasonSingleEntry = "single_entry_required" // ReasonMalformedEntry: an unknown, missing, repeated, empty or non-string // member, a value holding U+FFFD, or a mix of tool-call and list-call // members. ReasonMalformedEntry = "malformed_entry" // ReasonInvalidArgs: arguments_sha256 is not 64 lowercase hex characters. ReasonInvalidArgs = "invalid_arguments_hash" // ReasonInvalidMethod: method is not one of the list methods. ReasonInvalidMethod = "invalid_method" // ReasonIDJAGRequired: the entry was sent on a token exchange whose // requested_token_type is not the ID-JAG type, or on a request that is // neither token exchange nor ID-JAG redemption. ReasonIDJAGRequired = "id_jag_required" )
Reasons returned to the client. ReasonIDJAGRequired comes with invalid_request, every other reason with invalid_authorization_details. They are fixed strings and never carry request data.
const Type = "https://toolhive.dev/mcp_tool_call"
Type is the authorization_details type name of an MCP call entry.
Variables ¶
This section is empty.
Functions ¶
func IsListMethod ¶ added in v0.70.0
IsListMethod reports whether method is one of the methods a list-call entry may name: tools/list, prompts/list, resources/list or resources/templates/list, exactly.
func Register ¶
func Register(types map[string]authorizationdetails.Type)
Register adds the MCP call type to types, registered for RFC 8693 token exchange (where the hook accepts it only when an ID-JAG is requested), for authorizationdetails.IDJAGIssuance, which opts it into being signed into an ID-JAG that this server mints, and for the RFC 7523 JWT-bearer grant, which processes it on ID-JAG redemption; see the package doc. It overwrites an existing entry of the same name.
Types ¶
type Entry ¶
type Entry struct {
// Server is the ID of the vMCP backend the call is routed to.
Server string
// Tool is the request's params.name exactly as the client sends it.
Tool string
ArgumentsSHA256 string
OperationID string
Method string
}
Entry is one validated MCP call entry. Exactly one of the two shapes is set: a tool call has Tool, ArgumentsSHA256 and OperationID; a list call has Method. Server is always set. Build an Entry with ParseEntry, which enforces these rules.
func ParseEntry ¶
func ParseEntry(raw json.RawMessage) (Entry, error)
ParseEntry checks one JSON object against the MCP call shape and returns it as an Entry. The object must be valid UTF-8, have "type" equal to Type, hold only string members with no member repeated and no U+FFFD in any value, and match exactly one shape.
A rejection is an authorizationdetails.Error with code invalid_authorization_details and one of ReasonMalformedEntry, ReasonInvalidArgs or ReasonInvalidMethod.