Skip to main content
Glama

sodax_get_swap_tokens

Read-only

Retrieve available tokens for swapping on SODAX, with optional filtering by blockchain network to support token exchange operations.

Instructions

Get available tokens for swapping on SODAX, optionally filtered by chain

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNoFilter tokens by chain ID (e.g., 'base', 'ethereum', 'icon')
formatNoResponse format: 'json' for raw data or 'markdown' for formatted textmarkdown

Implementation Reference

  • MCP tool registration for sodax_get_swap_tokens - defines tool metadata, input schema (chainId, format), and the handler that calls getSwapTokens service and formats the response
    server.tool(
      "sodax_get_swap_tokens",
      "Get available tokens for swapping on SODAX, optionally filtered by chain",
      {
        chainId: z.string().optional()
          .describe("Filter tokens by chain ID (e.g., 'base', 'ethereum', 'icon')"),
        format: z.nativeEnum(ResponseFormat).optional().default(ResponseFormat.MARKDOWN)
          .describe("Response format: 'json' for raw data or 'markdown' for formatted text")
      },
      READ_ONLY,
      async ({ chainId, format }) => {
        try {
          const tokens = await getSwapTokens(chainId);
          const summary = chainId 
            ? `## Swap Tokens on ${chainId}\n\n${tokens.length} tokens available\n\n`
            : `## All Swap Tokens\n\n${tokens.length} tokens available across all chains\n\n`;
          return {
            content: [{
              type: "text",
              text: summary + formatResponse(tokens, format)
            }]
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}` }],
            isError: true
          };
        }
      }
    );
  • Service layer implementation of getSwapTokens - handles caching, makes HTTP GET requests to SODAX API endpoints (/config/swap/tokens or /config/swap/{chainId}/tokens), and returns array of SwapToken objects
    export async function getSwapTokens(chainId?: string): Promise<SwapToken[]> {
      const cacheKey = `tokens-${chainId || "all"}`;
      const cached = getCached<SwapToken[]>(cacheKey);
      if (cached) return cached;
    
      try {
        const endpoint = chainId ? `/config/swap/${chainId}/tokens` : "/config/swap/tokens";
        const response = await apiClient.get(endpoint);
        // API returns object keyed by chain ID, flatten if getting all
        const data = response.data;
        let tokens: SwapToken[] = [];
        if (chainId && Array.isArray(data)) {
          tokens = data;
        } else if (typeof data === "object" && !Array.isArray(data)) {
          // Flatten all chain tokens into single array
          for (const chain of Object.keys(data)) {
            const chainTokens = data[chain];
            if (Array.isArray(chainTokens)) {
              tokens.push(...chainTokens.map(t => ({ ...t, chainId: chain })));
            }
          }
        } else {
          tokens = data?.data || [];
        }
        setCache(cacheKey, tokens);
        return tokens;
      } catch (error) {
        console.error("Error fetching swap tokens:", error);
        throw new Error("Failed to fetch swap tokens from SODAX API");
      }
    }
  • Type definition for SwapToken interface - defines the structure of token data including address, chainId, symbol, name, decimals, logoUrl, and priceUsd
    export interface SwapToken {
      address: string;
      chainId: string;
      symbol: string;
      name: string;
      decimals: number;
      logoUrl?: string;
      priceUsd?: number;
    }
  • Tool registration with MCP server using server.tool() - registers sodax_get_swap_tokens with proper annotations and handler function
    server.tool(
      "sodax_get_swap_tokens",
      "Get available tokens for swapping on SODAX, optionally filtered by chain",
      {
        chainId: z.string().optional()
          .describe("Filter tokens by chain ID (e.g., 'base', 'ethereum', 'icon')"),
        format: z.nativeEnum(ResponseFormat).optional().default(ResponseFormat.MARKDOWN)
          .describe("Response format: 'json' for raw data or 'markdown' for formatted text")
      },
      READ_ONLY,
      async ({ chainId, format }) => {
        try {
          const tokens = await getSwapTokens(chainId);
          const summary = chainId 
            ? `## Swap Tokens on ${chainId}\n\n${tokens.length} tokens available\n\n`
            : `## All Swap Tokens\n\n${tokens.length} tokens available across all chains\n\n`;
          return {
            content: [{
              type: "text",
              text: summary + formatResponse(tokens, format)
            }]
          };
        } catch (error) {
          return {
            content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}` }],
            isError: true
          };
        }
      }
    );
  • Analytics mapping - maps sodax_get_swap_tokens to the 'api' group for PostHog tracking of tool usage
    sodax_get_swap_tokens: "api",
Behavior3/5

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

Annotations already declare readOnlyHint=true, openWorldHint=true, and destructiveHint=false, covering safety and scope. The description adds context about optional chain filtering and response formats, but doesn't disclose rate limits, pagination, or auth needs. No contradiction with annotations exists.

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, efficient sentence that front-loads the core purpose ('Get available tokens for swapping on SODAX') and adds optional detail ('optionally filtered by chain'). No wasted words or redundancy.

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

Completeness4/5

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

For a read-only tool with full schema coverage and annotations, the description is reasonably complete. It covers purpose and optional filtering, though lacks output details (no schema provided) and doesn't fully differentiate from all siblings. Given the tool's simplicity, it's mostly adequate.

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?

Schema description coverage is 100%, with clear docs for both parameters (chainId filtering and format options). The description mentions optional chain filtering, aligning with the schema but not adding extra meaning. With high schema coverage, baseline 3 is appropriate.

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?

The description clearly states the action ('Get available tokens for swapping') and resource ('on SODAX'), with optional filtering by chain. It distinguishes from siblings like 'sodax_get_supported_chains' (which lists chains) and 'sodax_get_token_supply' (which provides supply data), but doesn't explicitly differentiate from 'sodax_get_money_market_assets' (which might overlap in token listing).

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

Usage Guidelines3/5

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

The description implies usage when needing swap tokens, optionally filtered by chain, but doesn't specify when to use this vs. alternatives like 'sodax_get_supported_chains' for chain info or 'sodax_get_money_market_assets' for other token types. No explicit exclusions or prerequisites are mentioned.

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/gosodax/sodax-builders-mcp'

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