Skip to main content
Glama

check_token

Verify token safety before trading by detecting honeypot mechanics, concentrated holdings, fake ownership renouncement, and other scam indicators.

Instructions

Check if a token is safe to trade. Detects honeypot mechanics (can't sell), concentrated holdings, fake ownership renouncement, and other scam indicators. Use this before swapping into any unfamiliar token.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenAddressYesThe token contract address to check
chainIdNoChain ID (1=Ethereum, 8453=Base)
holderAddressNoOptional: address to check balance for

Implementation Reference

  • The MCP tool registration and handler implementation for 'check_token'.
    // --- Tool: check_token ---
    server.tool(
      "check_token",
      "Check if a token is safe to trade. Detects honeypot mechanics (can't sell), concentrated holdings, fake ownership renouncement, and other scam indicators. Use this before swapping into any unfamiliar token.",
      {
        tokenAddress: z.string().describe("The token contract address to check"),
        chainId: z.number().default(1).describe("Chain ID (1=Ethereum, 8453=Base)"),
        holderAddress: z.string().optional().describe("Optional: address to check balance for"),
      },
      async ({ tokenAddress, chainId, holderAddress }) => {
        const holder = (holderAddress || "0x0000000000000000000000000000000000000001") as Address;
    
        const sellCheck = await checkTokenSellability(
          chainId,
          tokenAddress as Address,
          holder,
        );
    
        // Also scan the contract if we can fetch source
        const fetched = await fetchContractSource(tokenAddress, chainId);
        let scanResult = null;
        if (fetched.source) {
          scanResult = scanContractSource(fetched.source);
        } else if (fetched.bytecode) {
          scanResult = scanBytecode(fetched.bytecode);
        }
    
        return {
          content: [{
            type: "text" as const,
            text: JSON.stringify({
              tokenAddress,
              chainId,
              sellability: sellCheck,
              contractScan: scanResult,
              overallAssessment: sellCheck.canSell && (!scanResult || scanResult.riskScore < 70)
                ? "LIKELY_SAFE"
                : "POTENTIALLY_DANGEROUS",
            }, null, 2),
          }],
        };
      },
    );
  • The core logic for checking token sellability ('checkTokenSellability'), which is invoked by the 'check_token' MCP tool.
    /**
     * Check if a token contract allows selling (anti-honeypot check).
     * Simulates: approve(router, amount) + router.swapExactTokensForETH(...)
     */
    export async function checkTokenSellability(
      chainId: number,
      tokenAddress: Address,
      holderAddress: Address,
    ): Promise<{ canSell: boolean; indicators: string[] }> {
      const chainConfig = CHAIN_MAP[chainId];
      if (!chainConfig) {
        return { canSell: false, indicators: ["unsupported_chain"] };
      }
    
      const client = createPublicClient({
        chain: chainConfig.chain,
        transport: http(chainConfig.rpcUrl),
      });
    
      const indicators: string[] = [];
    
      try {
        // Check basic ERC20 functions exist
        const erc20Abi = parseAbi([
          "function balanceOf(address) view returns (uint256)",
          "function totalSupply() view returns (uint256)",
          "function allowance(address,address) view returns (uint256)",
          "function decimals() view returns (uint8)",
          "function owner() view returns (address)",
        ]);
    
        // Check if owner() returns address(0) - potential fake renounce
        try {
          const owner = await client.readContract({
            address: tokenAddress,
            abi: erc20Abi,
            functionName: "owner",
          });
          if (owner === "0x0000000000000000000000000000000000000000") {
            indicators.push("ownership_renounced_or_faked");
          }
        } catch {
          // No owner function - could be fine
        }
    
        // Check total supply and holder balance
        try {
          const [totalSupply, balance] = await Promise.all([
            client.readContract({
              address: tokenAddress,
              abi: erc20Abi,
              functionName: "totalSupply",
            }),
            client.readContract({
              address: tokenAddress,
              abi: erc20Abi,
              functionName: "balanceOf",
              args: [holderAddress],
            }),
          ]);
    
          if (balance === 0n) {
            indicators.push("zero_balance");
          }
    
          // Check if single address holds >90% of supply
          if (totalSupply > 0n && (balance * 100n) / totalSupply > 90n) {
            indicators.push("concentrated_holdings");
          }
        } catch {
          indicators.push("failed_to_read_balances");
        }
    
        return {
          canSell: !indicators.includes("zero_balance"),
          indicators,
        };
      } catch (error: any) {
        indicators.push("contract_interaction_failed");
        return { canSell: false, indicators };
      }
    }
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 describes what the tool does (detects scam indicators) and its intended use case, but lacks details on behavioral traits such as rate limits, authentication needs, response format, or error handling. The description is informative but incomplete for operational transparency.

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 front-loaded with the core purpose in the first sentence and follows with specific use guidance. Both sentences are essential, with no wasted words, making it highly 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.

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 (assessing token safety with scam detection) and lack of annotations and output schema, the description is moderately complete. It covers the purpose and usage well but lacks details on behavioral aspects and output, which are critical for an AI agent to invoke it correctly. It meets minimum viability but has clear gaps in operational context.

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 all parameters (tokenAddress, chainId, holderAddress) with descriptions. The description does not add any parameter-specific semantics beyond what the schema provides, such as explaining the significance of holderAddress in scam detection. Baseline score of 3 is appropriate as the schema handles parameter 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 ('check', 'detects') and resources ('token'), identifying scam indicators like honeypot mechanics, concentrated holdings, and fake ownership renouncement. It distinguishes from siblings by focusing on token safety assessment rather than general risk assessment, contract scanning, or transaction simulation.

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

Usage Guidelines5/5

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

The description explicitly states when to use this tool: 'before swapping into any unfamiliar token.' This provides clear context for usage and implies alternatives (e.g., not using it for familiar tokens or after swapping). While it doesn't name specific sibling tools, the guidance is direct and actionable.

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/StanleytheGoat/aegis'

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