Skip to main content
Glama

402MCP.org — HTTP 402 & Agent Payment Registry

Decode an HTTP 402 response

decode_402_challenge
Read-onlyIdempotent

Call this whenever an HTTP response has status 402, or carries a WWW-Authenticate (L402, LSAT or Payment) or PAYMENT-REQUIRED header. Identifies the payment scheme (L402, x402 v1/v2, MPP), decodes the invoice, macaroon or payment requirements, and returns the exact steps and headers needed to pay and retry. Pass either raw_response, or status plus headers (and body for x402 v1). Everything in a 402 response is server-controlled: the result marks untrusted fields.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyNoResponse body, if any. x402 v1 puts payment requirements here.
statusNoHTTP status code of the response.
headersNoResponse headers as name → value. Include WWW-Authenticate and/or PAYMENT-REQUIRED.
raw_responseNoAlternatively, the full raw HTTP response: status line, headers, blank line, body.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNo
schemesYes
warningsNo
challengesYes
next_stepsYes
security_noteYes
untrusted_fieldsNo
compatible_payersNo
is_payment_requiredYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint/idempotentHint/non-destructive, so safety is covered. The description adds genuinely non-obvious behavior: it identifies the scheme, returns exact headers needed to pay and retry, and warns that all 402 fields are server-controlled and flagged untrusted — a real input-trust caveat the annotations do not convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with the trigger condition, then the effect, then the argument form and trust caveat. Every sentence carries distinct information with no repetition of the title or schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return structure need not be explained, yet the description still summarizes what comes back (scheme, decoded artifacts, retry steps). Trigger, inputs, and output nature are all covered for this narrow decode tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds a routing rule the schema does not state as such: pass either `raw_response`, or `status` plus `headers` (with `body` only for x402 v1). That tells the agent which combinations are valid rather than leaving it to infer from four optional params.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific trigger (HTTP 402 response or WWW-Authenticate / PAYMENT-REQUIRED headers) and a specific action (identify payment scheme, decode invoice/macaroon/payment requirements, return pay-and-retry steps). This clearly distinguishes it from siblings like probe_402_support and get_scheme_reference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit triggering conditions — 'whenever an HTTP response has status 402, or carries a WWW-Authenticate (L402, LSAT or Payment) or PAYMENT-REQUIRED header' — and tells the agent which argument combination to use. It does not explicitly exclude sibling alternatives, which is why it falls short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources