decode_402_challenge
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...
This record as markdown: /tools/402mcp-mcp/decode-402-challenge.md
What decode_402_challenge does on 402mcp
AI agents call decode_402_challenge to retrieve information from 402mcp without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.
| Parameter | Type | Required | Description |
|---|---|---|---|
body | string | — | Response body, if any. x402 v1 puts payment requirements here. |
status | integer | — | HTTP status code of the response. |
headers | object | — | Response headers as name → value. Include WWW-Authenticate and/or PAYMENT-REQUIRED. |
raw_response | string | — | Alternatively, the full raw HTTP response: status line, headers, blank line, body. |
Parameters from the server's own tool schema.
Why decode_402_challenge is rated Low
Even though decode_402_challenge only reads data, uncontrolled read access leaks sensitive information and racks up API costs: an agent caught in a retry loop can make thousands of calls a minute without anyone noticing.
Risk signalsAccepts raw HTML/template content (body) · Bulk/mass operation — affects multiple targets
Attacks that exploit this kind of access
The rule that runs decode_402_challenge safely
PolicyLayer is an MCP gateway: it sits between your AI agents and 402mcp, and checks every tool call against a rule you set before the call runs. Nothing changes on the server itself. For decode_402_challenge, this is the rule to start with:
decode_402_challenge is read-only, so it stays allowed. Everything else on the server is denied unless you say otherwise.
The button opens the PolicyLayer dashboard: create your workspace, connect 402mcp, apply this rule, and every decode_402_challenge call is checked against it from then on.
Questions about decode_402_challenge
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. It is categorised as a Read tool in the 402mcp MCP Server, which means it retrieves data without modifying state.
decode_402_challenge accepts 4 parameters: body, status, headers, raw_response. The full parameter table on this page comes from the server's own tool schema.
Register the 402 MCP server in PolicyLayer and add a rule for decode_402_challenge: allow, deny, rate-limit, or require approval. Point your MCP client at the PolicyLayer proxy URL and the rule is enforced on every call, before it reaches 402mcp. Nothing to install.
decode_402_challenge is a Read tool with low risk. Read-only tools are generally safe to allow by default.
Yes. Add a rate_limit block to the decode_402_challenge rule in your PolicyLayer policy. For example, setting max: 10 and window: 60 limits the tool to 10 calls per minute. Rate limits are tracked per agent session and reset automatically.
Set action: deny in the PolicyLayer policy for decode_402_challenge. The AI agent will receive a policy violation error and cannot call the tool. You can also include a reason field to explain why the tool is blocked.
decode_402_challenge is provided by the 402 MCP server (@402mcp/mcp). PolicyLayer sits as a proxy in front of this server to enforce policies before tool calls reach the server.
More on 402, and thousands of servers like it.
This server
Across the catalogue