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
| Name | Required | Description | Default |
|---|---|---|---|
| assetId | Yes | The ID of the RGB asset |
Implementation Reference
- src/server.ts:73-81 (handler)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 }; } }
- src/server.ts:70-72 (schema)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 }; } } );
- src/rgb-client.ts:56-58 (helper)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 }); }