get_balance
Retrieve the current balance from your connected Bitcoin Lightning wallet to monitor available funds for payments.
Instructions
Get the balance of the connected lightning wallet
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/nwc/get_balance.ts:18-35 (handler)The core handler function for the 'get_balance' tool. It retrieves the wallet balance using the NWC client, converts from millisats to sats, and formats the response with structured content.async () => { const balance = await client.getBalance(); // Convert millisats to sats const convertedBalance = { amount_in_sats: Math.floor(balance.balance / 1000), // Round down when converting millisats to sats as balance }; return { structuredContent: convertedBalance, content: [ { type: "text", text: JSON.stringify(convertedBalance, null, 2), }, ], }; }
- src/tools/nwc/get_balance.ts:11-17 (schema)The schema definition for the 'get_balance' tool, including title, description, and output schema using Zod.{ title: "Get Balance", description: "Get the balance of the connected lightning wallet", outputSchema: { amount_in_sats: z.number().describe("Current wallet balance in sats"), }, },
- src/tools/nwc/get_balance.ts:5-37 (registration)The registration function that registers the 'get_balance' tool on the MCP server, including the tool name, schema, and handler.export function registerGetBalanceTool( server: McpServer, client: nwc.NWCClient ) { server.registerTool( "get_balance", { title: "Get Balance", description: "Get the balance of the connected lightning wallet", outputSchema: { amount_in_sats: z.number().describe("Current wallet balance in sats"), }, }, async () => { const balance = await client.getBalance(); // Convert millisats to sats const convertedBalance = { amount_in_sats: Math.floor(balance.balance / 1000), // Round down when converting millisats to sats as balance }; return { structuredContent: convertedBalance, content: [ { type: "text", text: JSON.stringify(convertedBalance, null, 2), }, ], }; } ); }
- src/mcp_server.ts:27-27 (registration)The call to register the 'get_balance' tool during MCP server setup.registerGetBalanceTool(server, client);