Skip to main content
Glama
lordbasilaiassistant-sudo

base-flash-arb-mcp

get_mempool_pending

Detect pending transactions for a token on Base to identify potential front-running opportunities in arbitrage scenarios.

Instructions

Check pending transactions for a token (front-run detection). Note: Base L2 has minimal public mempool exposure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
token_addressYesToken contract address on Base

Implementation Reference

  • The tool 'get_mempool_pending' is registered and implemented in src/index.ts, which checks for pending transactions (or recent blocks as a proxy) for a given token address.
    server.tool(
      "get_mempool_pending",
      "Check pending transactions for a token (front-run detection). Note: Base L2 has minimal public mempool exposure.",
      {
        token_address: z.string().describe("Token contract address on Base"),
      },
      async ({ token_address }) => {
        try {
          const symbol = await getSymbol(token_address);
    
          // Base is an L2 with a sequencer - pending txs are not publicly visible
          // like on Ethereum mainnet. We can still check the pending block.
          let pendingTxs: Array<{
            hash: string;
            from: string;
            to: string | null;
            value: string;
            involvesToken: boolean;
          }> = [];
    
          try {
            const pendingBlock = await provider.getBlock("pending", true);
            if (pendingBlock && pendingBlock.prefetchedTransactions) {
              const tokenLower = token_address.toLowerCase();
    
              for (const tx of pendingBlock.prefetchedTransactions) {
                // Check if tx interacts with the token or known routers
                const isTokenDirect =
                  tx.to?.toLowerCase() === tokenLower;
                const isRouter =
                  tx.to?.toLowerCase() === UNIV2_ROUTER.toLowerCase() ||
                  tx.to?.toLowerCase() === UNIV3_QUOTER.toLowerCase() ||
                  tx.to?.toLowerCase() === AERO_ROUTER.toLowerCase();
    
                // Check if tx data contains the token address (without 0x prefix)
                const dataContainsToken =
                  tx.data &&
                  tx.data
                    .toLowerCase()
                    .includes(tokenLower.slice(2));
    
                if (isTokenDirect || (isRouter && dataContainsToken)) {
                  pendingTxs.push({
                    hash: tx.hash,
                    from: tx.from,
                    to: tx.to,
                    value: ethers.formatEther(tx.value),
                    involvesToken: true,
                  });
                }
              }
            }
          } catch {
            // Many Base RPC endpoints don't support pending block
          }
    
          // Also check recent confirmed blocks for rapid-fire activity (1-2 blocks)
          const currentBlock = await provider.getBlockNumber();
          const recentActivity: Array<{
            block: number;
            txCount: number;
            tokenTransfers: number;
          }> = [];
    
          for (let i = 0; i < 3; i++) {
            try {
              const block = await provider.getBlock(currentBlock - i, true);
              if (!block || !block.prefetchedTransactions) continue;
    
              let tokenTransfers = 0;
              const tokenLower = token_address.toLowerCase();
    
              for (const tx of block.prefetchedTransactions) {
                if (
                  tx.to?.toLowerCase() === tokenLower ||
                  (tx.data &&
                    tx.data.toLowerCase().includes(tokenLower.slice(2)))
                ) {
                  tokenTransfers++;
                }
              }
    
              recentActivity.push({
                block: block.number,
                txCount: block.prefetchedTransactions.length,
                tokenTransfers,
              });
            } catch {
              // Block fetch failed
            }
          }
    
          return {
            content: [
              {
                type: "text" as const,
                text: JSON.stringify(
                  {
                    token: token_address,
                    symbol,
                    pendingTransactions: pendingTxs.length,
                    pendingTxs,
                    recentBlocks: recentActivity,
                    note: "Base is an L2 with a centralized sequencer. The public mempool is minimal. Pending tx visibility is limited compared to Ethereum mainnet. Recent block activity is shown as a proxy for current trading intensity.",
                  },
                  null,
                  2
                ),
              },
            ],
          };
        } catch (e) {
          return {
            content: [
              {
                type: "text" as const,
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 of behavioral disclosure. It mentions 'front-run detection' and the note about 'minimal public mempool exposure,' which adds context about the tool's limitations and use case. However, it doesn't disclose other behavioral traits such as rate limits, authentication needs, or what the output might look like (e.g., transaction details, risk scores). This is a moderate gap given the lack of annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, with the main purpose stated first and an additional note provided for context. Both sentences earn their place by clarifying the tool's function and its limitations. However, it could be slightly more structured by explicitly separating usage guidelines, but it's still efficient with zero waste.

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 tool's complexity (involving blockchain mempool analysis) and the lack of annotations and output schema, the description is moderately complete. It covers the purpose and a key limitation, but doesn't explain return values, error handling, or detailed behavioral aspects. This leaves gaps that could hinder an AI agent's ability to use the tool effectively, though it's adequate as a minimum viable description.

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?

The input schema has 100% description coverage, with the parameter 'token_address' clearly documented as 'Token contract address on Base.' The description doesn't add any extra meaning beyond this, as it doesn't elaborate on parameter usage or constraints. According to the rules, with high schema coverage (>80%), the baseline is 3 even without param info in the description, which fits here.

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 tool's purpose: 'Check pending transactions for a token (front-run detection).' It specifies the verb ('Check'), resource ('pending transactions'), and context ('for a token'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'check_sandwich_risk' or 'detect_arb_opportunity', which might also involve transaction analysis, so it doesn't reach a perfect score.

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 provides implied usage context with 'front-run detection' and the note about 'Base L2 has minimal public mempool exposure,' suggesting this tool is for monitoring mempool activity on Base. However, it doesn't explicitly state when to use this tool versus alternatives like 'check_sandwich_risk' or 'detect_arb_opportunity,' nor does it provide exclusions or prerequisites, leaving some ambiguity for an AI agent.

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/lordbasilaiassistant-sudo/base-flash-arb-mcp'

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