Skip to main content
Glama
AdamikHQ

Adamik MCP Server

Official

getTokenDetails

Retrieve token metadata including decimals for converting raw blockchain balances to human-readable values. Essential for displaying accurate token amounts from getAccountState() across multiple chains.

Instructions

Fetches information about a non-native token (ERC-20, TRC-20, SPL, etc.) - not the chain's native currency. CRITICAL: This provides the 'decimals' field needed to convert raw token amounts from getAccountState() to human-readable values. Always call this for each token when displaying balances: human_readable = raw_amount ÷ 10^token_decimals

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdYes
tokenIdYes

Implementation Reference

  • The handler function that executes the getTokenDetails tool logic: makes an API request to fetch token details and returns the JSON-stringified response.
    async ({ chainId, tokenId }) => {
      const details = await makeApiRequest<GetTokenDetailsResponse>(
        `${ADAMIK_API_BASE_URL}/${chainId}/token/${tokenId}`,
        ADAMIK_API_KEY
      );
      const text = JSON.stringify(details);
      return {
        content: [
          {
            type: "text",
            text,
          },
        ],
      };
    }
  • src/module.ts:261-287 (registration)
    Registration of the 'getTokenDetails' tool on the McpServer instance, specifying name, description, input schema, and handler function.
    server.tool(
      "getTokenDetails",
      [
        "Fetches information about a non-native token (ERC-20, TRC-20, SPL, etc.) - not the chain's native currency.",
        "CRITICAL: This provides the 'decimals' field needed to convert raw token amounts from getAccountState() to human-readable values.",
        "Always call this for each token when displaying balances: human_readable = raw_amount ÷ 10^token_decimals",
      ].join(" "),
      {
        chainId: ChainIdSchema,
        tokenId: z.string(),
      },
      async ({ chainId, tokenId }) => {
        const details = await makeApiRequest<GetTokenDetailsResponse>(
          `${ADAMIK_API_BASE_URL}/${chainId}/token/${tokenId}`,
          ADAMIK_API_KEY
        );
        const text = JSON.stringify(details);
        return {
          content: [
            {
              type: "text",
              text,
            },
          ],
        };
      }
    );
  • Zod schemas defining the structure of the GetTokenDetailsResponse (including TokenInfoSchema), used for type safety in the handler's API response.
    export const TokenInfoSchema = z.object({
      type: TokenTypeSchema,
      id: z.string(),
      name: z.string(),
      ticker: z.string(),
      decimals: z.string(),
      contractAddress: z.string().optional(),
    });
    
    export const GetTokenDetailsResponseSchema = z.object({
      token: TokenInfoSchema,
    });
    export type GetTokenDetailsResponse = z.infer<typeof GetTokenDetailsResponseSchema>;

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/AdamikHQ/adamik-mcp-server'

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