Agent account SDK & local MCP

The @bruce/agent-sdk package and the bruce-agent-mcp server create the agent's key, sign up, keep the session fresh, and sign every payment on the agent's own machine.

TypeScript SDK

The SDK has no dependencies and uses WebCrypto. It runs on Node 20 and later, Deno, Bun, Workers and browsers.

import { BruceAgent } from "@bruce/agent-sdk";

// One time: creates the key and the account. Store `key` somewhere secret.
const { agent, key, account } = await BruceAgent.createAccount({
  displayName: "Research agent",
  username: "research_agent",
});

// Later: rebuild the client from the stored key.
const bruce = new BruceAgent({ key });

await bruce.balance();
await bruce.pay({ to: "alice", amount: "5.00", memo: "API credits" });
const details = await bruce.payDetails.share({ amount: "20" }); // handle, payUrl, wallet
await bruce.requests.create({ recipientUserId, amount: "12.00", memo: "Report" });
await bruce.paymentLinks.create({ amount: "9.99", memo: "Dataset" });
await bruce.escrow.relay(escrowId, "deposit");          // signed and auto-confirmed
await bruce.batch.send((await bruce.batch.create(rows)).batch.id);

// Any other prepare/submit pair:
await bruce.signedCall("/api/escrows/ID/relay/prepare", "/api/escrows/ID/relay", { action: "release" });
// Any other route:
await bruce.request("GET", "/api/notifications");

The SDK logs in again automatically before a session expires. Pass onSession to cache sessions, and orgId to act inside an organization.

Local MCP server

The hosted Bruce MCP spends a person's balance through delegated keys. The local server is different: it gives the agent its own account. The key is stored in ~/.bruce/agent.json with owner-only permissions and never leaves the machine.

{
  "mcpServers": {
    "bruce-agent": {
      "command": "npx",
      "args": ["-y", "@bruce/agent-mcp"],
      "env": { "BRUCE_API_BASE": "https://api.bruce.money" }
    }
  }
}

Tools:

Environment variables:

Back up the key file Whoever has agent.json controls the wallet. If you lose the file, Bruce cannot recover the funds.