zetrix_get_account_assets
Retrieve asset holdings for a Zetrix blockchain account, including specific assets by code and issuer when needed.
Instructions
Get asset holdings for an account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | The Zetrix account address | |
| code | No | Asset code (optional, must be used with issuer) | |
| issuer | No | Asset issuer address (optional, must be used with code) |
Implementation Reference
- src/zetrix-client.ts:359-386 (handler)Core handler implementation in ZetrixClient class. Makes HTTP GET request to Zetrix RPC /getAccountAssets endpoint with address (required) and optional code/issuer filters. Returns array of assets or empty array.async getAccountAssets( address: string, code?: string, issuer?: string ): Promise<ZetrixAccountAsset[]> { try { const params: any = { address }; if (code && issuer) { params.code = code; params.issuer = issuer; } const response = await this.client.get("/getAccountAssets", { params }); if (response.data.error_code !== 0) { throw new Error( response.data.error_desc || `API Error: ${response.data.error_code}` ); } return response.data.result.assets || []; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Failed to get account assets: ${error.message}`); } throw error; } }
- src/index.ts:155-176 (schema)Tool definition including name, description, and input schema (JSON Schema) specifying required 'address' and optional 'code'/'issuer' parameters.{ name: "zetrix_get_account_assets", description: "Get asset holdings for an account", inputSchema: { type: "object", properties: { address: { type: "string", description: "The Zetrix account address", }, code: { type: "string", description: "Asset code (optional, must be used with issuer)", }, issuer: { type: "string", description: "Asset issuer address (optional, must be used with code)", }, }, required: ["address"], }, },
- src/index.ts:888-905 (registration)MCP server request handler switch case that extracts arguments and delegates execution to ZetrixClient.getAccountAssets(), formats result as text content.case "zetrix_get_account_assets": { if (!args) { throw new Error("Missing arguments"); } const result = await zetrixClient.getAccountAssets( args.address as string, args.code as string | undefined, args.issuer as string | undefined ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; }
- src/zetrix-client.ts:69-76 (schema)TypeScript interface defining the structure of account asset objects returned by the handler.export interface ZetrixAccountAsset { amount: string; key: { code: string; issuer: string; }; }