Skip to main content
Glama
lnfi-network

RGB Lightning Network MCP Server

by lnfi-network

rgb_get_asset_balance

Retrieve the current balance of a specific RGB asset by providing its asset ID for asset management and tracking purposes.

Instructions

Get balance for a specific RGB asset

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assetIdYesThe ID of the RGB asset

Implementation Reference

  • Handler function for the 'rgb_get_asset_balance' MCP tool. It calls rgbClient.getAssetBalance(assetId), stringifies the result as JSON, and handles errors.
    async ({ assetId }) => {
      try {
        const balance = await rgbClient.getAssetBalance(assetId);
        return { content: [{ type: 'text', text: JSON.stringify(balance, null, 2) }] };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        return { content: [{ type: 'text', text: `Error: ${errorMessage}` }], isError: true };
      }
    }
  • Zod schema defining the input parameters for the tool: a required 'assetId' string.
    {
      assetId: z.string().describe('The ID of the RGB asset'),
    },
  • src/server.ts:67-82 (registration)
    Registration of the 'rgb_get_asset_balance' tool on the MCP server using server.tool(), including description, input schema, and handler function.
    server.tool(
      'rgb_get_asset_balance',
      'Get balance for a specific RGB asset',
      {
        assetId: z.string().describe('The ID of the RGB asset'),
      },
      async ({ assetId }) => {
        try {
          const balance = await rgbClient.getAssetBalance(assetId);
          return { content: [{ type: 'text', text: JSON.stringify(balance, null, 2) }] };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return { content: [{ type: 'text', text: `Error: ${errorMessage}` }], isError: true };
        }
      }
    );
  • Supporting method in RGBApiClientWrapper class that wraps the underlying RGB API SDK call to get the balance for a specific asset ID.
    async getAssetBalance(assetId: string) {
      return await this.client.rgb.getAssetBalance({ asset_id: assetId });
    }

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/lnfi-network/rgb-mcp-server'

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