Skip to main content
Glama
getAlby

Alby Bitcoin Payments MCP Server

Official

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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), }, ], }; }
  • 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"), }, },
  • 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), }, ], }; } ); }
  • The call to register the 'get_balance' tool during MCP server setup.
    registerGetBalanceTool(server, client);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/getAlby/mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server