Skip to main content
Glama
kukapay

liquidity-pools-mcp

get_liquidity_pools

Fetch liquidity pools for a token on a specific blockchain to analyze trading volume, market cap, and pool details from DexScreener API.

Instructions

Fetch all liquidity pools for a given chain ID and token address from DexScreener API.

Args:
    chain_id (str): The blockchain identifier (e.g., 'bsc' for Binance Smart Chain, 'eth' for Ethereum)
    token_address (str): The contract address of the token (e.g., '0xe6DF05CE8C8301223373CF5B969AFCb1498c5528')
    ctx (Context): MCP context for logging and request handling

Returns:
    str: A markdown table containing liquidity pool details including dexId, pairAddress, 
         base/quote token symbols, price USD, 24h buy/sell transactions, 24h volume, 
         liquidity USD, and market cap, followed by total liquidity USD

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chain_idYes
token_addressYes

Implementation Reference

  • main.py:10-70 (handler)
    The handler function decorated with @mcp.tool(), implementing the core logic to fetch liquidity pools from DexScreener API using httpx, process the data, build a markdown table, and handle errors.
    @mcp.tool()
    async def get_liquidity_pools(chain_id: str, token_address: str, ctx: Context) -> str:
        """
        Fetch all liquidity pools for a given chain ID and token address from DexScreener API.
        
        Args:
            chain_id (str): The blockchain identifier (e.g., 'bsc' for Binance Smart Chain, 'eth' for Ethereum)
            token_address (str): The contract address of the token (e.g., '0xe6DF05CE8C8301223373CF5B969AFCb1498c5528')
            ctx (Context): MCP context for logging and request handling
        
        Returns:
            str: A markdown table containing liquidity pool details including dexId, pairAddress, 
                 base/quote token symbols, price USD, 24h buy/sell transactions, 24h volume, 
                 liquidity USD, and market cap, followed by total liquidity USD
        """
        try:
            async with httpx.AsyncClient() as client:
                url = f"https://api.dexscreener.com/token-pairs/v1/{chain_id}/{token_address}"
                ctx.info(f"Fetching liquidity pools from {url}")
                
                response = await client.get(url)
                response.raise_for_status()
                
                pools = response.json()
                ctx.info(f"Retrieved {len(pools)} liquidity pools")
                
                # Calculate total liquidity
                total_liquidity = 0
                for pool in pools:
                    liquidity_usd = pool.get("liquidity", {}).get("usd", 0)
                    if isinstance(liquidity_usd, (int, float)):
                        total_liquidity += liquidity_usd
                
                # Build markdown table
                table = "| Dex ID | Pair Address | Base/Quote | Price USD | 24h Buys/Sells | 24h Volume | Liquidity USD | Market Cap |\n"
                table += "|--------|--------------|------------|-----------|----------------|------------|---------------|------------|\n"
                
                for pool in pools:
                    base_symbol = pool.get("baseToken", {}).get("symbol", "N/A")
                    quote_symbol = pool.get("quoteToken", {}).get("symbol", "N/A")
                    base_quote = f"{base_symbol}/{quote_symbol}"
                    price_usd = pool.get("priceUsd", "N/A")
                    txns_h24 = pool.get("txns", {}).get("h24", {})
                    buys_sells = f"{txns_h24.get('buys', 0)}/{txns_h24.get('sells', 0)}"
                    volume_h24 = pool.get("volume", {}).get("h24", "N/A")
                    liquidity_usd = pool.get("liquidity", {}).get("usd", "N/A")
                    market_cap = pool.get("marketCap", "N/A")
                    
                    table += f"| {pool.get('dexId', 'N/A')} | {pool.get('pairAddress', 'N/A')} | {base_quote} | {price_usd} | {buys_sells} | {volume_h24} | {liquidity_usd} | {market_cap} |\n"
                
                # Add total liquidity
                table += f"\n**Total Liquidity USD**: {total_liquidity}"
                
                return table
                
        except httpx.HTTPStatusError as e:
            ctx.error(f"HTTP error fetching liquidity pools: {str(e)}")
            return f"**Error**: HTTP error: {str(e)}"
        except Exception as e:
            ctx.error(f"Error fetching liquidity pools: {str(e)}")
            return f"**Error**: {str(e)}"
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's behavior: it fetches data from an external API (DexScreener), specifies the return format (a markdown table with detailed metrics), and mentions logging/request handling via the MCP context parameter. However, it lacks details on error handling, rate limits, or authentication requirements.

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 well-structured and front-loaded with the core purpose, followed by organized sections for Args and Returns. Every sentence adds value: the first sentence states the action, the Args section details parameters with examples, and the Returns section specifies the output format. There is no wasted text.

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?

Given the tool's moderate complexity (2 parameters, no annotations, no output schema), the description is largely complete. It covers the purpose, parameters, and return format adequately. However, it lacks information on potential errors, rate limits, or authentication, which would be helpful for a tool interacting with an external API.

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

Parameters5/5

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

The description adds significant meaning beyond the input schema, which has 0% description coverage. It provides concrete examples for both parameters (e.g., 'bsc' for chain_id, a sample token address), clarifies data types (str), and explains the purpose of each parameter in the context of the API call. This fully compensates for the schema's lack of documentation.

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 specific action ('Fetch all liquidity pools') with the target resource ('for a given chain ID and token address from DexScreener API'). It provides a complete verb+resource+source combination that leaves no ambiguity about what the tool does, especially since there are no sibling tools to differentiate from.

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 context through the parameter explanations (e.g., chain ID examples like 'bsc' and 'eth'), but does not explicitly state when to use this tool versus alternatives. With no sibling tools mentioned, there's no guidance on tool selection, though the parameter details offer some practical context for appropriate usage.

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/kukapay/liquidity-pools-mcp'

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