Skip to main content
Glama
lordbasilaiassistant-sudo

base-security-scanner-mcp

get_contract_info

Retrieve contract metadata on Base mainnet including bytecode size, ETH balance, transaction count, and token details to analyze security risks.

Instructions

Get basic contract metadata on Base mainnet: is it a contract, bytecode size, ETH balance, transaction count. For tokens, also returns name/symbol/supply.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesContract or EOA address on Base mainnet

Implementation Reference

  • The tool `get_contract_info` handler implementation. It uses `getBasicContractInfo` and `getTokenMetadata` to fetch and format contract data.
    // Tool 6: get_contract_info
    server.tool(
      "get_contract_info",
      "Get basic contract metadata on Base mainnet: is it a contract, bytecode size, ETH balance, transaction count. For tokens, also returns name/symbol/supply.",
      {
        address: z.string().describe("Contract or EOA address on Base mainnet"),
      },
      async ({ address }) => {
        try {
          const info = await getBasicContractInfo(address);
    
          let tokenInfo: Record<string, unknown> | null = null;
          if (info.isContract) {
            tokenInfo = await getTokenMetadata(address);
            if (tokenInfo) {
              tokenInfo = serializeBigInts(tokenInfo) as Record<string, unknown>;
            }
          }
    
          return ok({
            ...info,
            tokenMetadata: tokenInfo,
          });
        } catch (err) {
          return fail(`get_contract_info failed: ${err instanceof Error ? err.message : String(err)}`);
        }
      }
    );
  • Helper function used by `get_contract_info` to retrieve basic information about a contract/address.
    async function getBasicContractInfo(address: string): Promise<Record<string, unknown>> {
      const [code, balance, txCount] = await Promise.all([
        provider.getCode(address),
        provider.getBalance(address),
        provider.getTransactionCount(address),
      ]);
    
      const isContract = code !== "0x" && code.length > 2;
      const bytecodeSize = isContract ? (code.length - 2) / 2 : 0;
    
      return {
        address,
        isContract,
        bytecodeSize,
        balanceETH: ethers.formatEther(balance),
        balanceWei: balance.toString(),
        transactionCount: txCount,
      };
    }
  • Helper function used by `get_contract_info` to fetch ERC-20 metadata if applicable.
    async function getTokenMetadata(address: string): Promise<Record<string, unknown> | null> {
      const contract = new ethers.Contract(address, ERC20_ABI, provider);
      const [name, symbol, decimals, totalSupply] = await Promise.all([
        safeCall(() => contract.name()),
        safeCall(() => contract.symbol()),
        safeCall(() => contract.decimals()),
        safeCall(() => contract.totalSupply()),
      ]);
    
      if (!name && !symbol) return null;
    
      return {
        name: name ?? "Unknown",
        symbol: symbol ?? "???",
        decimals: decimals !== null ? Number(decimals) : 18,
        totalSupply: totalSupply !== null ? totalSupply.toString() : "0",
        totalSupplyFormatted: totalSupply !== null && decimals !== null
          ? ethers.formatUnits(totalSupply, Number(decimals))
          : "unknown",
      };
    }
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 the network (Base mainnet) and specific data returned (contract status, bytecode size, ETH balance, transaction count, token details). However, it lacks information on rate limits, error conditions, or response format, which are important for a tool with no output schema.

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 two concise sentences with zero waste. The first sentence front-loads the core purpose and key data points, while the second adds token-specific details efficiently.

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 no annotations and no output schema, the description is moderately complete for a simple query tool. It covers the network scope and data returned, but lacks details on response structure, error handling, or limitations, which are needed for full contextual understanding.

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 the single parameter. The description adds context by specifying the parameter must be a 'Contract or EOA address on Base mainnet', but this is redundant with the schema's description. No additional syntax or format details are provided beyond the schema.

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 ('Get basic contract metadata') and resources involved (contracts on Base mainnet). It distinguishes from siblings by specifying the scope of returned data (metadata vs. analysis/audit tools like analyze_bytecode or audit_report).

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 for retrieving basic metadata on Base mainnet, but does not explicitly state when to use this tool versus alternatives like scan_contract or check_token_permissions. No exclusions or prerequisites are mentioned.

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-security-scanner-mcp'

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