Skip to main content
Glama

get_token_pools_v2

Retrieve Uniswap V2 token pairs by token address and generate a markdown-formatted table with details like pair ID, volume, and reserves for easy analysis and integration.

Instructions

Query all Uniswap V2 pairs for a specific token and return as a formatted markdown table.

Parameters:
    token_address (str): The Ethereum address of the token to query (e.g., '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48').
    ctx (Context): The API context for logging and error handling.

Returns:
    A markdown-formatted string containing a table with columns: Version, ID, Pair, Volume USD, ReserveUSD.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYes

Implementation Reference

  • main.py:481-513 (handler)
    The handler function for the 'get_token_pools_v2' tool, registered via @mcp.tool(). It queries Uniswap V2 pairs for the specified token address using the helper function query_pairs_v2, constructs a pandas DataFrame, and returns a markdown-formatted table of results.
    @mcp.tool()
    async def get_token_pools_v2(token_address: str, ctx: Context) -> str:
        """
        Query all Uniswap V2 pairs for a specific token and return as a formatted markdown table.
    
        Parameters:
            token_address (str): The Ethereum address of the token to query (e.g., '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48').
            ctx (Context): The API context for logging and error handling.
    
        Returns:
            A markdown-formatted string containing a table with columns: Version, ID, Pair, Volume USD, ReserveUSD.
        """
        ctx.info(f"Querying V2 pairs for token: {token_address}")
        
        try:
            pairs = await query_pairs_v2(token_address)
            ctx.info(f"Found {len(pairs)} V2 pairs")
            
            # Create DataFrame directly from pairs list
            df = pd.DataFrame([
                {
                    "Version": "v2",
                    "ID": pair.id,
                    "Pair": pair.pair,
                    "Volume USD": pair.volumeUSD,
                    "ReserveUSD": pair.reserveUSD
                }
                for pair in pairs
            ])
            return df.to_markdown(index=False)
        except Exception as e:
            ctx.error(f"Failed to query V2 pairs: {str(e)}")
            raise
  • Supporting helper function that performs the GraphQL query to the Uniswap V2 subgraph to fetch all pairs containing the given token, ordered by volumeUSD descending, and parses the response into a list of Pair dataclasses.
    async def query_pairs_v2(token_address: str) -> List[Pair]:
        query = """
        query($token: ID!) {
            pairs(
                where: { 
                    or: [
                        {token0: $token},
                        {token1: $token}
                    ]
                }
                orderBy: volumeUSD
                orderDirection: desc
            ) {
                id
                token0 {
                    id
                    symbol
                }
                token1 {
                    id
                    symbol
                }
                reserveUSD
                volumeUSD
            }
        }
        """
        
        async with httpx.AsyncClient() as client:
            response = await client.post(
                UNISWAP_V2_SUBGRAPH,
                headers={
                    "Authorization": f"Bearer {API_KEY}"
                },
                json={
                    "query": query,
                    "variables": {"token": token_address.lower()}
                }
            )
            response.raise_for_status()
            data = response.json()
            
            if "errors" in data:
                raise ValueError(f"GraphQL errors: {data['errors']}")
                
            return [
                Pair(
                    id=pair["id"],
                    token0=pair["token0"]["id"],
                    token1=pair["token1"]["id"],
                    reserveUSD=pair["reserveUSD"],
                    volumeUSD=pair["volumeUSD"],
                    pair=f"{pair['token0']['symbol']}/{pair['token1']['symbol']}"
                )
                for pair in data["data"]["pairs"]
            ]
  • main.py:33-41 (schema)
    Dataclass schema defining the structure of Uniswap V2 pair data used by the handler and helper.
    @dataclass
    class Pair:
        id: str
        token0: str
        token1: str
        reserveUSD: str
        volumeUSD: str
        pair: str  # Format: token0.symbol/token1.symbol
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses that the tool queries data and returns a formatted markdown table, which indicates a read-only operation without mutation. However, it lacks details on behavioral traits such as error handling, rate limits, or authentication needs, leaving gaps in transparency for a tool with no annotation support.

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 appropriately sized and front-loaded, starting with the core purpose, followed by clear parameter and return value sections. Every sentence adds value without redundancy, making it efficient and well-structured for quick understanding.

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 complexity (querying Uniswap pairs) and no annotations or output schema, the description is mostly complete: it explains the purpose, parameters, and return format. However, it lacks details on potential errors, data freshness, or limitations, which could be useful for full contextual understanding in a financial data context.

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?

Schema description coverage is 0%, so the description must compensate. It adds significant meaning beyond the input schema by explaining the token_address parameter with an example (e.g., Ethereum address format) and clarifying the ctx parameter for logging and error handling, even though ctx is not in the schema. This fully compensates for the lack of schema 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 tool's purpose with specific verbs ('Query all Uniswap V2 pairs for a specific token') and resource ('Uniswap V2 pairs'), distinguishing it from sibling tools like get_token_pools_v3 and get_token_pools_v4 by specifying the V2 version. It also mentions the output format ('formatted markdown table'), making the purpose explicit and differentiated.

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

Usage Guidelines4/5

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

The description implies usage context by specifying 'for a specific token' and the V2 version, which helps differentiate it from siblings like get_pool_data or other versions. However, it does not explicitly state when to use this tool versus alternatives (e.g., no direct comparison or exclusion criteria), so it provides clear context but lacks explicit guidance on alternatives.

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

Related 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/uniswap-pools-mcp'

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