Repository navigation
docs(0358): pay per request in the agent skill - #442
Conversation
Three routes have keyless /x402/v1 twins since 0356. The skill offers them beside the free key: the stellar-x402 MCP tools when the agent has them, else a short script on the upstream @x402/fetch, capped at one cent a payment. Testnet preview: XLM and USDC only. The key steps follow the shared sign-in: signing in issues no key, the Prices API tab's Get API Key does.
The skill told the agent to ask for the payer's secret key, which puts it in the transcript; the user now sets it in the MCP server's config or in STELLAR_SECRET_KEY. After the payment was sent, a 402 with a PAYMENT-RESPONSE, a 502 or a 504 may still settle (the crate's settlement_failed and its /settle timeout), so the skill no longer says nothing is charged until the answer is below 400. The facilitator link pointed at a host whose root answers 404, and the overview's revision history gets its row for the /x402/v1 twins.
The errors table told an agent to retry every 500, 502 and 504. On the paid routes a 502 or 504 can come after the payment was sent, and the transfer may still land, as the pay-per-request section already says: check the payer's last transaction before paying again.
Without a key the skill told the agent to stop and ask for one, and it paid with the connector as soon as it had the tools. akot's access flow (2026-12-02): the agent offers the ways in that fit the request, each with its cost, and waits: the stellar-x402 connector (first when its tools are there), a free key through Discord, setting the connector up, or the script. Outside the testnet sandbox only the key is offered. No payment before the user has heard the price and said yes. The connector's setup is summarized and linked to the stellar-x402 README. The script blocks are unchanged.
The connector's setup cloned the default branch, which has neither search_resources nor the listing guard: it now clones develop. The pay sections act only on the user's choice and yes, and the quote before the first payment covers the whole task. Step 1 states what every paid way in costs and the sandbox's candles exactly, and recommends .env, since an export in another terminal does not reach the agent. The task's evidence now holds the final run, with P6 (the user says the payer key is in .env).
An agent told the user to export STELLAR_SECRET_KEY, as the script section said. An export in another terminal never reaches the agent, so the script would stop with "STELLAR_SECRET_KEY is not set". The section now asks for the project's .env and says why, as Step 1 already does for the API key. Found in akot's manual run with a connector that has no payer.
stkrolikiewicz
left a comment
There was a problem hiding this comment.
Looks good to me; one small precision nit below, non-blocking.
| | ----------- | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | 400 | `{"code": "invalid_id" \| "invalid_query" \| "invalid_body", "message": ...}` | `message` names the bad parameter. Fix it; do not retry as-is. | | ||
| | 403 | `{"message": "Forbidden"}` | Missing, wrong or disabled key. Check the key is set and sent as `x-api-key`. Do not suggest Regenerate. No 401 in production. | | ||
| | 402 | Terms in the `PAYMENT-REQUIRED` header | Only on `/x402/v1`: the request's price. An x402 client pays it and retries. One after a payment may still settle. | |
There was a problem hiding this comment.
Nit: "One after a payment may still settle" drops the condition. In stellar-x402's axum layer a /verify refusal is a 402 with {"error": ...} and no PAYMENT-RESPONSE, and it never settles; only settlement_failed (after /settle) carries PAYMENT-RESPONSE. The Pay per request section says it right. Maybe: "One that carries a PAYMENT-RESPONSE may still settle; without one it was refused: read its error." (as SorobanScan's skill words it).
There was a problem hiding this comment.
Fixed in 977cdd3 with that wording. I checked it against the layer at the rev Prices pins (ff5933c2): a refused /verify is a 402 with {"error"} and no PAYMENT-RESPONSE; only settlement_failed carries one.
Only a 402 that carries a PAYMENT-RESPONSE (a failed settlement) may still settle; one without it is a refused verification with an error. From stkrolikiewicz's review of #442.
Summary
skills/stellar-prices-api/SKILL.mdgets a second path beside the free key: pay per request through the/x402/v1/twins from 0356, as a testnet preview (XLM and USDC,ohlcv1h/24h, batch ≤ 5). With the stellar-x402 MCP tools when the agent has them (as in the Claude Desktop run, stellar-x402 0042), else a short script on the upstream@x402/fetch2.x, capped at $0.01 a payment./api/docs/prices.docs/prices-api-general-overview.md§4/§7: the key is required on/v1, not on the paid twins.SKILL.mdand run unchanged (3 settlements), and freshclaude -p --model sonnetagents with only the skill bought XLM's price, one through the MCP tools and one through the script. Hashes in the task file.master, so agents get it with the next release; the card's description changes in a separate PR to stellar/stellar-dev-skill.Access flow (akot, 2026-12-02)
With no key the skill no longer stops at "get a key":
STELLAR_PRICES_API_KEY(environment, then.env). With a key:/v1, nothing else offered. Without one, the agent offers the ways in that fit the request, each with its cost, and waits for the choice: the stellar-x402 connector (first whencall_paid_httpis among its tools), a free key through Discord (walked through step by step), setting the connector up, or the script. A request outside the testnet sandbox gets only the key, with the reason.apps/mcp-local/README.md#claude-desktop; it clonesdevelop, sincemainhas nosearch_resourcesorlistingyet..env: both the API key and the script'sSTELLAR_SECRET_KEY. Anexportin another terminal never reaches the agent.502or504on/x402/v1after the payment was sent may still settle, so check the payer's last transaction before paying again.Verified 2026-12-02 with fresh
claude -p --model sonnetagents, each transcript checked by a script. Before the change, an agent with no key and no connector never mentioned the connector. After it:call_paid_http,8814c5c6…f43e..env→ asked before paying..env→/v1at once, no menu.The script blocks are byte-identical to 2026-12-01's, and their testnet run passed again. Details in the task file.