set_budget
Set or update spending limits for agents in a Bitcoin Lightning wallet system to control autonomous payments and API access.
Instructions
Set or update budget limit for an agent. REQUIRES OPERATOR KEY.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | Yes | Agent ID to update | |
| budget_limit_sats | Yes | New budget limit in sats (0 for unlimited) |
Implementation Reference
- src/index.ts:1251-1267 (handler)MCP tool handler for "set_budget" in index.ts.
case 'set_budget': { const parsed = SetBudgetSchema.parse(args); const result = await session.requireClient().setBudget(parsed.agent_id, parsed.budget_limit_sats); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Budget updated to ${parsed.budget_limit_sats} sats`, agent_id: result.agentId, new_budget_limit_sats: result.newBudgetLimitSats, }, null, 2), }, ], }; } - src/lightning-faucet.ts:721-739 (handler)Implementation of the setBudget method in the LightningFaucetClient class.
async setBudget(agentId: number, budgetLimitSats: number): Promise<{ agentId: number; newBudgetLimitSats: number; rawResponse: ApiResponse; }> { const result = await this.request<ApiResponse & { agent_id?: number; budget_limit_sats?: number; }>('update_agent', { agent_id: agentId, updates: { budget_limit_sats: budgetLimitSats === 0 ? null : budgetLimitSats }, }); return { agentId: result.agent_id || agentId, newBudgetLimitSats: budgetLimitSats, rawResponse: result, }; } - src/index.ts:183-186 (schema)Zod schema definition for the set_budget tool.
const SetBudgetSchema = z.object({ agent_id: z.number().int().positive().describe('Agent ID to update'), budget_limit_sats: z.number().int().min(0).describe('New budget limit in sats (0 for unlimited)'), }); - src/index.ts:545-555 (registration)Tool registration in the ListToolsRequestSchema handler.
name: 'set_budget', description: 'Set or update budget limit for an agent. REQUIRES OPERATOR KEY.', inputSchema: { type: 'object', properties: { agent_id: { type: 'integer', description: 'Agent ID to update' }, budget_limit_sats: { type: 'integer', minimum: 0, description: 'New budget limit in sats (0 for unlimited)' }, }, required: ['agent_id', 'budget_limit_sats'], }, },