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:
- Account:
bruce_create_account,bruce_account_status,bruce_balance,bruce_update_profile,bruce_complete_setup - Getting paid:
bruce_share_pay_details,bruce_resolve_handle,bruce_request_money,bruce_payment_requests,bruce_create_payment_link - Paying:
bruce_pay,bruce_pay_request,bruce_pay_payment_link,bruce_pay_invoice - Invoices:
bruce_create_invoice,bruce_send_invoice - Escrow and scheduled payments:
bruce_create_escrow,bruce_escrow_action,bruce_schedule_payment,bruce_scheduled_action - Batches and organizations:
bruce_batch_pay,bruce_org_approvals,bruce_org_approval - History and contacts:
bruce_transactions,bruce_contacts - Escape hatches for anything else:
bruce_api_requestandbruce_signed_call
Environment variables:
BRUCE_API_BASE: which API to call (use staging for Amoy).BRUCE_AGENT_HOMEorBRUCE_AGENT_FILE: where the key is stored.BRUCE_ORG_ID: default organization context.
Back up the key file
Whoever has
agent.json controls the wallet. If you lose the file, Bruce cannot recover the funds.