Skip to main content
Glama

sodax_get_swap_tokens

Read-only

Retrieve swap tokens available on SODAX, optionally filtered by chain ID for targeted results.

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

  • The MCP tool registration for 'sodax_get_swap_tokens'. Defines the Zod schema (chainId optional string, format optional enum), uses READ_ONLY annotations, and the handler calls getSwapTokens(chainId) from the service layer, formats a summary prefix, and returns the result.
    // Tool 2: Get Swap Tokens
    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
          };
        }
      }
    );
  • The service function getSwapTokens() that performs the actual API call. Optionally accepts a chainId, builds the endpoint (/config/swap/{chainId}/tokens or /config/swap/tokens), fetches from the SODAX API, flattens the response (handles both array and object-keyed formats), caches results, and returns SwapToken[].
    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");
      }
    }
  • The SwapToken interface defining the shape of each token returned: address, chainId, symbol, name, decimals, logoUrl (optional), and priceUsd (optional).
    export interface SwapToken {
      address: string;
      chainId: string;
      symbol: string;
      name: string;
      decimals: number;
      logoUrl?: string;
      priceUsd?: number;
    }
  • The registerSodaxApiTools(server) function is called from src/index.ts line 44 to register all SODAX tools, including sodax_get_swap_tokens via server.tool().
    export function registerSodaxApiTools(server: McpServer): void {
      
      // Tool 1: Get Supported Chains
      server.tool(
        "sodax_get_supported_chains",
        "List all blockchain networks supported by SODAX for cross-chain swaps and DeFi operations",
        {
          format: z.nativeEnum(ResponseFormat).optional().default(ResponseFormat.MARKDOWN)
            .describe("Response format: 'json' for raw data or 'markdown' for formatted text")
        },
        READ_ONLY,
        async ({ format }) => {
          try {
            const chains = await getSupportedChains();
            return {
              content: [{
                type: "text",
                text: formatResponse(chains, format)
              }]
            };
          } catch (error) {
            return {
              content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : "Unknown error"}` }],
              isError: true
            };
          }
        }
      );
    
      // Tool 2: Get Swap Tokens
      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
            };
          }
        }
      );
  • src/index.ts:44-48 (registration)
    Registration call: registerSodaxApiTools(server) is invoked on line 44 to register all SODAX tools into the MCP server instance.
      registerSodaxApiTools(server);
      await registerGitBookProxyTools(server);
    
      return server;
    }
Behavior3/5

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

Annotations already mark the tool as read-only and non-destructive. The description adds the ability to filter by chain, which is also in the schema, but provides no additional behavioral details beyond the schema.

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, well-structured sentence that conveys the main purpose without any unnecessary words.

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 simple retrieval tool with two optional parameters and no output schema, the description adequately conveys the core functionality. It doesn't explain response structure, but the format parameter covers that.

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 coverage is 100%, so the description adds no new meaning for parameters beyond what the schema already provides. The 'optionally filtered by chain' is a restatement of the chainId parameter.

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

Purpose5/5

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

The description clearly states the tool retrieves available swap tokens on SODAX with optional chain filtering, effectively distinguishing it from sibling tools like sodax_get_money_market_tokens or sodax_get_hub_assets.

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 the tool is for obtaining swap tokens, but lacks explicit guidance on when to use it over similar tools or when to avoid it.

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

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