Skip to main content
Glama

resolve_asset

Convert CAIP-19 asset identifiers into detailed token metadata including address, decimals, symbol, name, network, chainId, and registration status for blockchain operations.

Instructions

Resolve a CAIP-19 asset identifier to token metadata. Returns address, decimals, symbol, name, network, chainId, isNative, isRegistered.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
asset_idYesCAIP-19 asset identifier (e.g., "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "eip155:1/slip44:60")

Implementation Reference

  • Implementation of the 'resolve_asset' tool handler. It parses CAIP-19 asset IDs and queries the daemon's registry for metadata.
    server.tool(
      'resolve_asset',
      'Resolve a CAIP-19 asset identifier to token metadata. Returns address, decimals, symbol, name, network, chainId, isNative, isRegistered.',
      {
        asset_id: z.string().describe(
          'CAIP-19 asset identifier (e.g., "eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "eip155:1/slip44:60")',
        ),
      },
      async (args) => {
        const parsed = parseAssetIdLocal(args.asset_id);
        if (!parsed) {
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({
                error: true,
                code: 'INVALID_CAIP19',
                message: `Invalid CAIP-19 format: "${args.asset_id}". Expected format: {chainId}/{namespace}:{reference}`,
              }),
            }],
            isError: true,
          };
        }
    
        const { chainId, isNative, address } = parsed;
    
        // For native assets, we can return immediately without registry lookup
        if (isNative) {
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({
                assetId: args.asset_id,
                chainId,
                network: chainId,
                address: null,
                decimals: null,
                symbol: null,
                name: null,
                isNative: true,
                isRegistered: false,
              }),
            }],
          };
        }
    
        // Query the daemon's token registry using the CAIP-2 chainId as network
        const registryResult = await apiClient.get(
          `/v1/tokens?network=${encodeURIComponent(chainId)}`,
        );
    
        if (!registryResult.ok) {
          // Registry lookup failed -- return partial info from CAIP-19 parsing
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({
                assetId: args.asset_id,
                chainId,
                network: chainId,
                address,
                decimals: null,
                symbol: null,
                name: null,
                isNative: false,
                isRegistered: false,
              }),
            }],
          };
        }
    
        // Search registry for matching token by address
        const data = registryResult.data as {
          tokens?: Array<{
            address: string;
            symbol: string;
            name: string;
            decimals: number;
            [key: string]: unknown;
          }>;
        };
    
        const tokens = data.tokens ?? [];
        const normalizedAddress = address?.toLowerCase() ?? '';
        const match = tokens.find(
          (t) => t.address.toLowerCase() === normalizedAddress,
        );
    
        if (match) {
          return {
            content: [{
              type: 'text' as const,
              text: JSON.stringify({
                assetId: args.asset_id,
                chainId,
                network: chainId,
                address: match.address,
                decimals: match.decimals,
                symbol: match.symbol,
                name: match.name,
                isNative: false,
                isRegistered: true,
              }),
            }],
          };
        }
    
        // Token not found in registry
        return {
          content: [{
            type: 'text' as const,
            text: JSON.stringify({
              assetId: args.asset_id,
              chainId,
              network: chainId,
              address,
              decimals: null,
              symbol: null,
              name: null,
              isNative: false,
              isRegistered: false,
            }),
          }],
        };
      },
    );
  • Registration function for the 'resolve_asset' tool.
    export function registerResolveAsset(server: McpServer, apiClient: ApiClient): void {

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/minhoyoo-iotrust/WAIaaS'

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