Skip to main content
Glama
k-lordbodin7

PancakeSwap PoolSpy MCP Server

by k-lordbodin7

get_new_pools_bsc

Monitor recently created PancakeSwap V3 liquidity pools on BNB Smart Chain to identify new trading opportunities and analyze DeFi market activity.

Instructions

Returns a list of trading pools created in the specified time range on Pancake Swap V3 BNB Smart Chain.

Parameters: time_range_seconds (int): The time range in seconds to look back for new pools. Default is 300 seconds (5 minutes). limit (int): The maximum number of pools to return. Default is 100 pools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
time_range_secondsNo
limitNo

Implementation Reference

  • main.py:68-98 (handler)
    The main tool handler for 'get_new_pools_bsc', registered via @mcp.tool() decorator. Fetches recent pools using subgraph query and formats output as a string.
    @mcp.tool()
    async def get_new_pools_bsc(time_range_seconds: int = 300, limit: int = 100) -> str:
        """
        Returns a list of trading pools created in the specified time range on Pancake Swap V3 BNB Smart Chain.
    
        Parameters:
            time_range_seconds (int): The time range in seconds to look back for new pools.
                                      Default is 300 seconds (5 minutes).
            limit (int): The maximum number of pools to return.
                         Default is 100 pools.
        """
        try:
            pools = await fetch_recent_pools(time_range_seconds=time_range_seconds, limit=limit)
            time_range_minutes = time_range_seconds // 60  # Convert to minutes for display
            output = f"Newly Created Trading Pools (Last {time_range_minutes} Minutes, Limit: {limit}):\n"
            for pool in pools:
                timestamp = datetime.fromtimestamp(int(pool["createdAtTimestamp"])).strftime('%Y-%m-%d %H:%M:%S')
                volume_usd = float(pool["volumeUSD"])  # Ensure float for formatting
                tvl_usd = float(pool["totalValueLockedUSD"])  # Ensure float for formatting
                output += (
                    f"Pool Address: {pool['id']}\n"
                    f"Tokens: {pool['token0']['symbol']}/{pool['token1']['symbol']}\n"
                    f"Created At: {timestamp}\n"
                    f"Block Number: {pool['createdAtBlockNumber']}\n"
                    f"Transaction Count: {pool['txCount']}\n"
                    f"Volume (USD): {volume_usd:.2f}\n"
                    f"Total Value Locked (USD): {tvl_usd:.2f}\n\n"
                )
            return output if pools else f"No pools created in the last {time_range_minutes} minutes."
        except Exception as e:
            return f"Error fetching new pools: {str(e)}"
  • main.py:35-65 (helper)
    Core helper function that constructs and executes the GraphQL query to retrieve recently created pools from the PancakeSwap V3 subgraph.
    async def fetch_recent_pools(time_range_seconds: int = 300, limit: int = 100) -> list[dict]:
        time_ago = int((datetime.utcnow() - timedelta(seconds=time_range_seconds)).timestamp())
        query = """
        query RecentPools($timestamp: BigInt!, $limit: Int!) {
            pools(
                where: { createdAtTimestamp_gt: $timestamp }
                orderBy: createdAtTimestamp
                orderDirection: desc
                first: $limit
            ) {
                id
                token0 { symbol }
                token1 { symbol }
                createdAtTimestamp
                createdAtBlockNumber
                txCount
                volumeUSD
                totalValueLockedUSD
            }
        }
        """
        variables = {"timestamp": str(time_ago), "limit": limit}  # Convert timestamp to string for BigInt
        try:
            result = await query_subgraph(query, variables)
            pools = result.get("data", {}).get("pools", [])
            if not pools:
                print(f"No pools found for timestamp > {time_ago}. Response: {json.dumps(result, indent=2)}")
            return pools
        except Exception as e:
            print(f"Error in fetch_recent_pools: {str(e)}")
            raise
  • main.py:21-32 (helper)
    Utility helper for executing GraphQL queries against the configured PancakeSwap subgraph endpoint.
    async def query_subgraph(query: str, variables: dict = None) -> dict:
        async with httpx.AsyncClient(timeout=10.0) as client:
            payload = {"query": query}
            if variables:
                payload["variables"] = variables
            response = await client.post(SUBGRAPH_URL, json=payload)
            if response.status_code != 200:
                raise Exception(f"Subgraph query failed with status {response.status_code}: {response.text}")
            result = response.json()
            if "errors" in result:
                raise Exception(f"GraphQL errors: {json.dumps(result['errors'], indent=2)}")
            return result
  • main.py:68-68 (registration)
    The @mcp.tool() decorator registers the get_new_pools_bsc function as an MCP tool.
    @mcp.tool()
Behavior2/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 describes the retrieval behavior but lacks details on potential side effects (e.g., rate limits, authentication needs, data freshness, or error handling). While it specifies the scope (new pools in a time range), it does not disclose behavioral traits like pagination, sorting, or what happens if no pools are found, leaving gaps for a read operation.

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: the first sentence states the core purpose, followed by a structured parameter list with clear explanations and defaults. Every sentence adds value without redundancy, making it efficient and easy to scan.

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

Completeness3/5

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

Given the complexity (a read operation with two parameters), no annotations, and no output schema, the description is moderately complete. It covers the purpose and parameters well but lacks details on return values (e.g., pool structure, fields) and behavioral aspects like error handling or performance. This leaves some gaps for an agent to use the tool effectively without additional context.

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

Parameters4/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 meaningful semantics by explaining that 'time_range_seconds' is 'the time range in seconds to look back for new pools' with a default, and 'limit' is 'the maximum number of pools to return' with a default. This clarifies the purpose and usage of both parameters beyond what the schema provides, though it could include more on constraints (e.g., min/max values).

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 ('Returns a list'), resource ('trading pools'), and scope ('created in the specified time range on Pancake Swap V3 BNB Smart Chain'). It distinguishes this as a retrieval operation for newly created pools with temporal filtering, making the purpose immediately understandable without redundancy.

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 by specifying the time range for new pools, but it does not provide explicit guidance on when to use this tool versus alternatives (e.g., for historical vs. real-time data, or other filtering criteria). Since no sibling tools are listed, the lack of comparative guidance is less critical, but it still lacks explicit when/when-not directives.

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/k-lordbodin7/pancakeswap-poolspy-mcp'

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