create_agent
Create a new agent with spending limits to autonomously manage Bitcoin Lightning payments and access paid APIs through the Lightning Wallet MCP server.
Instructions
Create a new agent under your operator account. Returns the agent API key.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for the agent | |
| description | No | Optional description | |
| budget_limit_sats | No | Optional spending limit in sats |
Implementation Reference
- src/index.ts:1038-1059 (handler)Handler for 'create_agent' tool call, uses the LightningFaucetClient to create a new agent.
case 'create_agent': { const parsed = CreateAgentSchema.parse(args); const result = await session.requireClient().createAgent( parsed.name, parsed.description, parsed.budget_limit_sats ); return { content: [ { type: 'text', text: JSON.stringify({ success: true, message: `Agent "${result.name}" created successfully`, agent_id: result.agentId, api_key: result.agentApiKey, name: result.name, }, null, 2), }, ], }; } - src/lightning-faucet.ts:451-478 (handler)Implementation of createAgent in LightningFaucetClient, which sends the request to the backend.
async createAgent( name: string, description?: string, budgetLimitSats?: number ): Promise<{ agentId: number; agentApiKey: string; name: string; rawResponse: CreateAgentResponse; }> { const data: Record<string, unknown> = { name }; if (description) data.description = description; if (budgetLimitSats !== undefined) data.budget_limit_sats = budgetLimitSats; const result = await this.request<CreateAgentResponse>('create_agent', data); const apiKey = result.agent_api_key || result.api_key; if (!apiKey) { throw new Error('No agent API key returned'); } return { agentId: result.agent_id || 0, agentApiKey: apiKey, name: result.name || name, rawResponse: result, }; } - src/index.ts:134-138 (schema)Input schema validation for the create_agent tool.
const CreateAgentSchema = z.object({ name: z.string().describe('Name for the agent'), description: z.string().optional().describe('Optional description'), budget_limit_sats: z.number().min(0).optional().describe('Optional spending limit in sats'), }); - src/index.ts:415-426 (registration)MCP tool registration for create_agent.
name: 'create_agent', description: 'Create a new agent under your operator account. Returns the agent API key.', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name for the agent' }, description: { type: 'string', description: 'Optional description' }, budget_limit_sats: { type: 'integer', minimum: 0, description: 'Optional spending limit in sats' }, }, required: ['name'], }, },