get_balance
Retrieve the current balance from your connected Lightning wallet using the MCP server, enabling quick access to your payment details and funds.
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 handler function for the get_balance tool. Fetches the wallet balance using the NWC client, converts from millisats to sats, and returns structured content with the balance.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:10-17 (schema)Tool schema definition including name, title, description, and output schema using Zod for the balance amount in sats."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"), }, },
- src/tools/nwc/get_balance.ts:5-37 (registration)Registers the get_balance tool on the MCP server, including 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)Invokes the registration of the get_balance tool during MCP server creation.registerGetBalanceTool(server, client);