getAccountState
Retrieve account state (balances and staking positions) for blockchain networks, ensuring raw amounts are converted to human-readable formats using mandatory API calls to avoid display errors.
Instructions
Get the state of an account (balances and staking positions). CRITICAL: Balance amounts are returned in SMALLEST UNITS (wei for ETH, satoshis for BTC, µATOM for ATOM, etc.). NEVER show raw amounts to users! Always convert first! MANDATORY CONVERSION STEPS - ALWAYS CALL THESE ENDPOINTS: 1. For NATIVE currency: MUST call listFeatures(chainId) first to get the exact decimal places - NEVER assume! 2. For TOKENS: MUST call getTokenDetails(chainId, tokenId) for each token to get its exact decimals - NEVER assume! 3. Convert ALL amounts: human_readable = raw_amount ÷ 10^decimals (using the decimals from the API calls above) 4. Present in human-readable format to users COMMON ERRORS TO AVOID: • ATOM: Raw '4191769000' with 6 decimals = 4.191769 ATOM (NOT 4,191.769 ATOM!) • ETH: Raw '5354656887913579' with 18 decimals = 0.005354656887913579 ETH (NOT 5.35 ETH!) • Always divide by 10^decimals, check your decimal point placement!
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | ||
| chainId | Yes |
Implementation Reference
- src/module.ts:338-353 (handler)The asynchronous handler function that performs the core logic: fetches account state from the Adamik API using makeApiRequest and returns it formatted as MCP text content.async ({ chainId, accountId }: GetAccountStatePathParams) => { const state = await makeApiRequest<GetAccountStateResponse>( `${ADAMIK_API_BASE_URL}/${chainId}/account/${accountId}/state`, ADAMIK_API_KEY ); const text = JSON.stringify(state); return { content: [ { type: "text", text, }, ], }; }
- src/module.ts:316-354 (registration)The MCP server.tool() call that registers the 'getAccountState' tool, providing name, detailed description, input schema, and the handler function.server.tool( "getAccountState", [ "Get the state of an account (balances and staking positions).", "CRITICAL: Balance amounts are returned in SMALLEST UNITS (wei for ETH, satoshis for BTC, µATOM for ATOM, etc.).", "NEVER show raw amounts to users! Always convert first!", "\n", "MANDATORY CONVERSION STEPS - ALWAYS CALL THESE ENDPOINTS:", "1. For NATIVE currency: MUST call listFeatures(chainId) first to get the exact decimal places - NEVER assume!", "2. For TOKENS: MUST call getTokenDetails(chainId, tokenId) for each token to get its exact decimals - NEVER assume!", "3. Convert ALL amounts: human_readable = raw_amount ÷ 10^decimals (using the decimals from the API calls above)", "4. Present in human-readable format to users", "\n", "COMMON ERRORS TO AVOID:", "• ATOM: Raw '4191769000' with 6 decimals = 4.191769 ATOM (NOT 4,191.769 ATOM!)", "• ETH: Raw '5354656887913579' with 18 decimals = 0.005354656887913579 ETH (NOT 5.35 ETH!)", "• Always divide by 10^decimals, check your decimal point placement!", ].join(" "), { chainId: ChainIdSchema, accountId: z.string(), }, async ({ chainId, accountId }: GetAccountStatePathParams) => { const state = await makeApiRequest<GetAccountStateResponse>( `${ADAMIK_API_BASE_URL}/${chainId}/account/${accountId}/state`, ADAMIK_API_KEY ); const text = JSON.stringify(state); return { content: [ { type: "text", text, }, ], }; } );
- src/schemas.ts:276-280 (schema)Zod schema and TypeScript type definition for the input path parameters of getAccountState (chainId and accountId). Used for type safety in the handler.export const GetAccountStatePathParamsSchema = z.object({ chainId: ChainIdSchema, accountId: z.string(), }); export type GetAccountStatePathParams = z.infer<typeof GetAccountStatePathParamsSchema>;
- src/schemas.ts:341-346 (schema)Zod schema and TypeScript type definition for the response structure from getAccountState, including balances (native, tokens, staking).export const GetAccountStateResponseSchema = z.object({ chainId: ChainIdSchema, accountId: z.string(), balances: AccountBalancesSchema, }); export type GetAccountStateResponse = z.infer<typeof GetAccountStateResponseSchema>;