Skip to main content
Glama

discover_pools

Find Cardano DEX liquidity pools for specific native tokens using Iris API data to analyze trading opportunities.

Instructions

Discover Cardano DEX liquidity pools for a native token via Iris API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesCardano token symbol (INDY, SNEK, MIN, NIGHT)

Implementation Reference

  • The main handler implementation of the discover_pools tool. It fetches liquidity pools from the Iris API for a given Cardano token symbol, filters pools matching the token's policy ID, sorts by TVL, and returns pool details including DEX name, TVL, reserves, price, and active status.
    server.tool(
      'discover_pools',
      'Discover Cardano DEX liquidity pools for a native token via Iris API',
      {
        symbol: z.string().describe('Cardano token symbol (INDY, SNEK, MIN, NIGHT)'),
      },
      async ({ symbol }) => {
        const upper = symbol.toUpperCase();
        const token = SUPPORTED_TOKENS[upper];
        if (!token) {
          throw new Error(
            `Unsupported token: ${symbol}. Supported: ${Object.keys(SUPPORTED_TOKENS).join(', ')}`
          );
        }
    
        const allPools = await fetchIrisPools();
        const tokenPools = allPools
          .filter((p: any) => matchesToken(p, token.policyId))
          .sort((a: any, b: any) => (b.state?.tvl || 0) - (a.state?.tvl || 0));
    
        return {
          content: [
            {
              type: 'text' as const,
              text: JSON.stringify(
                {
                  symbol: upper,
                  totalPools: tokenPools.length,
                  pools: tokenPools.map((p: any) => ({
                    identifier: p.identifier,
                    dex: p.dex || 'unknown',
                    tvl: p.state?.tvl || 0,
                    reserveA: p.state?.reserveA || 0,
                    reserveB: p.state?.reserveB || 0,
                    price: p.state?.price || null,
                    isActive: p.isActive !== false,
                  })),
                  timestamp: new Date().toISOString(),
                },
                null,
                2
              ),
            },
          ],
        };
      }
    );
  • Helper function fetchIrisPools() that fetches liquidity pools data from the Iris API endpoint. Used by discover_pools to retrieve all available pools.
    async function fetchIrisPools(): Promise<any[]> {
      const resp = await fetch(`${IRIS_BASE_URL}/api/liquidity-pools`, {
        headers: { 'User-Agent': 'OpenMM-MCP-Agent/1.0' },
        signal: AbortSignal.timeout(10000),
      });
      if (!resp.ok) {
        throw new Error(`Iris API error: ${resp.status}`);
      }
      const data = await resp.json();
      return data?.data || data || [];
    }
  • Helper function matchesToken() that checks if a pool contains a token with a specific policy ID. Used by discover_pools to filter pools for the requested token.
    function matchesToken(pool: any, policyId: string): boolean {
      const tokenA = pool.pair?.tokenA || pool.tokenA;
      const tokenB = pool.pair?.tokenB || pool.tokenB;
      return tokenA?.policyId === policyId || tokenB?.policyId === policyId;
    }
  • The registerCardanoTools function that registers both get_cardano_price and discover_pools tools with the MCP server. The discover_pools tool is registered starting at line 198.
    export function registerCardanoTools(server: McpServer): void {
      server.tool(
        'get_cardano_price',
        'Get aggregated price for a Cardano native token from DEX liquidity pools (TOKEN/USDT via ADA bridge)',
        {
          symbol: z.string().describe('Cardano token symbol (INDY, SNEK, MIN, NIGHT)'),
        },
        async ({ symbol }) => {
          const upper = symbol.toUpperCase();
          const token = SUPPORTED_TOKENS[upper];
          if (!token) {
            throw new Error(
              `Unsupported token: ${symbol}. Supported: ${Object.keys(SUPPORTED_TOKENS).join(', ')}`
            );
          }
    
          const [adaPrice, allPools] = await Promise.all([fetchADAUSDT(), fetchIrisPools()]);
    
          const tokenPools = allPools
            .filter((p: any) => matchesToken(p, token.policyId))
            .filter((p: any) => (p.state?.tvl || 0) >= token.minLiquidity)
            .sort((a: any, b: any) => (b.state?.tvl || 0) - (a.state?.tvl || 0))
            .slice(0, 3);
    
          if (tokenPools.length === 0) {
            throw new Error(`No liquidity pools found for ${upper} above minimum TVL threshold`);
          }
    
          const identifiers = tokenPools.map((p: any) => p.identifier).filter(Boolean);
          let tokenAdaPrice: number;
    
          if (identifiers.length > 0) {
            const prices = await fetchIrisPrices(identifiers);
            if (prices.length > 0) {
              const totalTvl = tokenPools.reduce((sum: number, p: any) => sum + (p.state?.tvl || 0), 0);
              tokenAdaPrice = tokenPools.reduce((sum: number, p: any, i: number) => {
                const weight = (p.state?.tvl || 0) / totalTvl;
                return sum + (prices[i] || 0) * weight;
              }, 0);
            } else {
              tokenAdaPrice =
                tokenPools.reduce((sum: number, p: any) => sum + (p.state?.price || 0), 0) /
                tokenPools.length;
            }
          } else {
            tokenAdaPrice =
              tokenPools.reduce((sum: number, p: any) => sum + (p.state?.price || 0), 0) /
              tokenPools.length;
          }
    
          const tokenUsdtPrice = tokenAdaPrice * adaPrice.price;
          const confidence = Math.min(tokenPools.length / 3, 1);
    
          return {
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(
                  {
                    symbol: `${upper}/USDT`,
                    price: tokenUsdtPrice,
                    tokenAdaPrice,
                    adaUsdtPrice: adaPrice.price,
                    confidence,
                    poolsUsed: tokenPools.length,
                    sources: {
                      ada: adaPrice.sources,
                      pools: tokenPools.map((p: any) => ({
                        dex: p.dex || 'unknown',
                        tvl: p.state?.tvl,
                      })),
                    },
                    timestamp: new Date().toISOString(),
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      );
    
      server.tool(
        'discover_pools',
        'Discover Cardano DEX liquidity pools for a native token via Iris API',
        {
          symbol: z.string().describe('Cardano token symbol (INDY, SNEK, MIN, NIGHT)'),
        },
        async ({ symbol }) => {
          const upper = symbol.toUpperCase();
          const token = SUPPORTED_TOKENS[upper];
          if (!token) {
            throw new Error(
              `Unsupported token: ${symbol}. Supported: ${Object.keys(SUPPORTED_TOKENS).join(', ')}`
            );
          }
    
          const allPools = await fetchIrisPools();
          const tokenPools = allPools
            .filter((p: any) => matchesToken(p, token.policyId))
            .sort((a: any, b: any) => (b.state?.tvl || 0) - (a.state?.tvl || 0));
    
          return {
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(
                  {
                    symbol: upper,
                    totalPools: tokenPools.length,
                    pools: tokenPools.map((p: any) => ({
                      identifier: p.identifier,
                      dex: p.dex || 'unknown',
                      tvl: p.state?.tvl || 0,
                      reserveA: p.state?.reserveA || 0,
                      reserveB: p.state?.reserveB || 0,
                      price: p.state?.price || null,
                      isActive: p.isActive !== false,
                    })),
                    timestamp: new Date().toISOString(),
                  },
                  null,
                  2
                ),
              },
            ],
          };
        }
      );
    }
  • src/worker.ts:18-47 (registration)
    Worker endpoint that exposes the MCP server capabilities, listing discover_pools as one of the available tools in the server card JSON response.
    if (url.pathname === '/.well-known/mcp/server-card.json' && request.method === 'GET') {
      const card = {
        name: 'openmm-mcp-agent',
        version: '1.0.4',
        description:
          'MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents',
        url: 'https://openmm-mcp.qbtlabs.io/mcp',
        transport: { type: 'streamable-http' },
        capabilities: {
          tools: [
            { name: 'get_ticker' },
            { name: 'get_orderbook' },
            { name: 'get_trades' },
            { name: 'get_balance' },
            { name: 'list_orders' },
            { name: 'create_order' },
            { name: 'cancel_order' },
            { name: 'cancel_all_orders' },
            { name: 'start_grid_strategy' },
            { name: 'stop_strategy' },
            { name: 'get_strategy_status' },
            { name: 'get_cardano_price' },
            { name: 'discover_pools' },
          ],
        },
      };
      return new Response(JSON.stringify(card), {
        headers: { 'Content-Type': 'application/json' },
      });
    }
Behavior2/5

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

With no annotations, the description carries full burden but lacks behavioral details. It doesn't disclose if this is a read-only operation, potential rate limits, error conditions, or what the output might look like (e.g., list of pools with details). The description is minimal and adds little beyond the basic action.

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 with zero waste. It front-loads the key information (action and resource) and avoids unnecessary details, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete for a tool that likely returns complex data (e.g., pool listings). It doesn't explain return values, error handling, or behavioral traits, leaving significant gaps for the agent to operate effectively.

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%, so the schema already documents the single parameter 'symbol' with examples. The description adds no additional meaning beyond implying it's for a native token, which is redundant with the schema's examples. Baseline 3 is appropriate as the schema does the heavy lifting.

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 ('Discover') and resource ('Cardano DEX liquidity pools for a native token'), specifying it operates via the Iris API. It distinguishes from siblings like get_orderbook or get_ticker by focusing on pools rather than orders or prices, though it doesn't explicitly contrast with them.

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 is provided on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing a token symbol, or differentiate from similar tools like get_ticker, leaving the agent to infer usage based on the purpose alone.

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/QBT-Labs/openmm-mcp'

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