Skip to content

Integrations

Terminal window
curl -H "X-Spendctl-Agent: researcher" "http://127.0.0.1:8402/https://api.example.com/report?id=42"

Or send the target in X-Spendctl-Target and request http://127.0.0.1:8402/. spendctl adds x-spendctl-attempt, x-spendctl-decision and x-spendctl-amount to responses.

import { wrapFetch, readRefusal, AgentClient } from "@spendctl/client";
const pay = wrapFetch({ agent: "researcher" });
const res = await pay("https://api.example.com/report");
const refusal = await readRefusal(res); // undefined when paid or free
const budget = await new AgentClient({ agent: "researcher" }).budget();
Terminal window
claude mcp add spendctl -e SPENDCTL_AGENT=researcher -- npx spendctl mcp

Tools: pay (fetch a URL that may cost money), check_budget, list_receipts. The MCP server is a thin client: no keys, no approvals.

Terminal window
spendctl run --agent researcher -- python agent.py

Sets HTTP_PROXY (with the agent name in the proxy credentials). Plain http:// requests are governed; https:// is tunnelled without inspection, so paid HTTPS APIs should use the gateway URL.

  • Claude Agent SDK — pass the MCP server through mcpServers.
  • OpenAI Agents SDK — a function tool over wrapFetch.
  • LangGraph — tool() + createReactAgent over wrapFetch.

Runnable examples for these three are planned for the public client SDK repository, github.com/miraistudio/spendctl-sdk.

spendctl reads and forwards W3C baggage entries spend.root, spend.parent, spend.depth. If your agent is itself a paid service, propagate incoming baggage to outgoing calls (OpenTelemetry does this for you). spendctl trace <attempt-id> prints the tree.