Skip to main content
Glama
unixlamadev-spec

lightningprox-mcp

get_balance

Check remaining balance on a LightningProx spend token to monitor prepaid access for AI models. Returns balance in sats.

Instructions

Check the remaining balance on a LightningProx spend token. Returns balance in sats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
spend_tokenYesLightningProx spend token (starts with lnpx_)

Implementation Reference

  • The getBalance function fetches the balance from the API using the provided spend token.
    async function getBalance(spendToken: string): Promise<any> {
      const res = await fetch(`${LIGHTNINGPROX_URL}/v1/balance`, {
        headers: { "X-Spend-Token": spendToken },
      });
      if (!res.ok) {
        const err = await res.json() as any;
        throw new Error(err.error || `Balance check failed: ${res.status}`);
      }
      return res.json();
    }
  • src/index.ts:62-75 (registration)
    Tool registration definition for "get_balance".
      name: "get_balance",
      description:
        "Check the remaining balance on a LightningProx spend token. Returns balance in sats.",
      inputSchema: {
        type: "object",
        properties: {
          spend_token: {
            type: "string",
            description: "LightningProx spend token (starts with lnpx_)",
          },
        },
        required: ["spend_token"],
      },
    },
  • MCP request handler logic for "get_balance".
    case "get_balance": {
      const { spend_token } = args as any;
      const data = await getBalance(spend_token);
    
      const sats = data.balance_sats ?? data.sats ?? data.balance ?? "?";
      const usd = data.balance_usd != null ? ` (~$${Number(data.balance_usd).toFixed(4)})` : "";
    
      return {
        content: [
          {
            type: "text",
            text: `⚡ Balance: ${sats} sats${usd}\n\nToken: ${spend_token.slice(0, 16)}…\nTop up: ${LIGHTNINGPROX_URL}/topup`,
          },
        ],
      };
    }

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/unixlamadev-spec/lightningprox-mcp'

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