paybondpaybond
Sign in

Claude Agent SDK spend controls

Guard Claude Agent SDK custom tools with Paybond in-process MCP — Harbor verify before handlers run and auto-evidence after paid tool success.

The Claude Agent SDK registers paid work through in-process MCP tool() definitions. Paybond wraps those handlers so Harbor verifies spend before execution and auto-submits evidence after success. Built-in Claude tools (Read, Bash, etc.) pass through unguarded.

Beta: The Claude Agent SDK is evolving. Treat this adapter as beta until Anthropic stabilizes the SDK.

TypeScript and Python parity — use the tab matching your runtime below.

Try it

Terminal
Terminal commandSwipe to inspect long lines
paybond login
paybond agent demo claude-agents smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format table

Scaffold

Terminal
Terminal commandSwipe to inspect long lines
paybond init agent-middleware --framework claude-agents --out paybond-claude-agents.ts
paybond policy init --preset travel --out paybond.policy.yaml

paybond-session.ts

Code exampleSwipe to inspect long lines
import { tool, query } from "@anthropic-ai/claude-agent-sdk";
import { z } from "zod";
import { Paybond } from "@paybond/kit";

const paybond = await Paybond.open({ apiKey: process.env.PAYBOND_API_KEY! });

const sdkTools = [
  tool(
    "travel.book_hotel",
    "Book a hotel room",
    { city: z.string(), estimatedPriceCents: z.number() },
    async (args) => ({
      content: [{ type: "text", text: JSON.stringify(await bookHotel(args)) }],
      structuredContent: await bookHotel(args),
    }),
  ),
];

const { claudeAgentsConfig } = await paybond.agent({
  policy: "travel",
  framework: "claude-agents",
  tools: sdkTools,
});

const { mcpServer, allowedTools } = claudeAgentsConfig!;

await query({
  prompt: "Book a hotel in Lisbon under budget.",
  options: {
    mcpServers: { paybond: mcpServer },
    allowedTools,
  },
});

Install extras: pip install "paybond-kit[claude-agents]".

Production bind

Use deferred paybond.instrument() without sandbox: true, then bind per session:

const instrumented = await paybond.instrument({
  policy: "./paybond.policy.yaml",
  framework: "claude-agents",
  tools: sdkTools,
});
const runtime = await instrumented.bind({ intentId, capabilityToken });
// runtime.claudeAgentsConfig → pass to query()

Developer reference: /docs/kit/claude-agents.