Skip to main content
Glama

get_tokens

Retrieve registered tokens, including built-in and custom, for a specified blockchain network.

Instructions

Get registered tokens (builtin + custom) for a specific network.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
networkYesNetwork identifier (e.g., "ethereum-sepolia", "polygon-amoy" or CAIP-2 "eip155:1").

Implementation Reference

  • The registerGetTokens function registers the 'get_tokens' tool on the MCP server. The handler accepts a 'network' parameter, sends a GET request to /v1/tokens?network=... via the ApiClient, and returns the result as a CallToolResult.
    export function registerGetTokens(server: McpServer, apiClient: ApiClient, walletContext?: WalletContext): void {
      server.tool(
        'get_tokens',
        withWalletPrefix('Get registered tokens (builtin + custom) for a specific network.', walletContext?.walletName),
        {
          network: z.string().describe('Network identifier (e.g., "ethereum-sepolia", "polygon-amoy" or CAIP-2 "eip155:1").'),
        },
        async (args) => {
          const params = new URLSearchParams();
          params.set('network', args.network);
          const result = await apiClient.get('/v1/tokens?' + params.toString());
          return toToolResult(result);
        },
      );
    }
  • Input schema for get_tokens: a single required 'network' field (string) described as a network identifier (e.g., 'ethereum-sepolia', 'polygon-amoy' or CAIP-2). Validated via zod.
    {
      network: z.string().describe('Network identifier (e.g., "ethereum-sepolia", "polygon-amoy" or CAIP-2 "eip155:1").'),
    },
  • Registration of get_tokens tool inside createMcpServer: registerGetTokens(server, apiClient, walletContext) is called at line 92.
    registerGetTokens(server, apiClient, walletContext);
  • Import statement for registerGetTokens from './tools/get-tokens.js' in the server factory module.
    import { registerGetTokens } from './tools/get-tokens.js';
  • The toToolResult helper function converts ApiResult to CallToolResult format. Used by the get_tokens handler to format the API response.
    export function toToolResult<T>(result: ApiResult<T>): CallToolResult {
      if ('ok' in result && result.ok) {
        return {
          content: [{ type: 'text', text: JSON.stringify(result.data) }],
        };
      }
    
      if ('expired' in result && result.expired) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              session_expired: true,
              message: result.message,
              action: 'Run waiaas mcp setup to get a new token',
            }),
          }],
          // NO isError (H-04: prevents Claude Desktop from disconnecting)
        };
      }
    
      if ('networkError' in result && result.networkError) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              network_error: true,
              message: result.message,
            }),
          }],
          // NO isError
        };
      }
    
      // Actual API error -- isError: true
      if ('error' in result) {
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              error: true,
              ...result.error,
            }),
          }],
          isError: true,
        };
      }
    
      // Should never happen -- fallback
      return {
        content: [{ type: 'text', text: JSON.stringify({ error: true, message: 'Unknown error' }) }],
        isError: true,
      };
    }
    
    /**
     * Convert ApiResult to MCP resource result format (ReadResourceResult).
     */
    export function toResourceResult<T>(uri: string, result: ApiResult<T>): ReadResourceResult {
      if ('ok' in result && result.ok) {
        return {
          contents: [{
            uri,
            text: JSON.stringify(result.data),
            mimeType: 'application/json',
          }],
        };
      }
    
      if ('expired' in result && result.expired) {
        return {
          contents: [{
            uri,
            text: JSON.stringify({
              session_expired: true,
              message: result.message,
              action: 'Run waiaas mcp setup to get a new token',
            }),
            mimeType: 'application/json',
          }],
        };
      }
    
      if ('networkError' in result && result.networkError) {
        return {
          contents: [{
            uri,
            text: JSON.stringify({
              network_error: true,
              message: result.message,
            }),
            mimeType: 'application/json',
          }],
        };
      }
    
      if ('error' in result) {
        return {
          contents: [{
            uri,
            text: JSON.stringify({
              error: true,
              ...result.error,
            }),
            mimeType: 'application/json',
          }],
        };
      }
    
      return {
        contents: [{
          uri,
          text: JSON.stringify({ error: true, message: 'Unknown error' }),
          mimeType: 'application/json',
        }],
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must disclose behavioral traits. It only says 'Get registered tokens', implying a read operation, but lacks details such as authentication requirements, rate limits, or any potential side effects. Minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no wasted words. It is front-loaded and immediately conveys the purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one parameter and no output schema, the description provides the essential action but omits any details about return format, pagination, or token types. It is minimally adequate but could be more complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema covers the parameter 'network' with a description including examples, achieving 100% coverage. The tool description adds no additional meaning beyond what the schema already provides, so it meets the baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description states 'Get registered tokens (builtin + custom) for a specific network' with a verb and resource, clearly indicating the action and scope. However, it does not differentiate from sibling tools like 'get_assets' or 'list_nfts' which might overlap in functionality, reducing clarity slightly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives, such as when to prefer 'get_tokens' over 'get_assets' or 'list_nfts'. The description only states what it does, not when it's appropriate or inappropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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