Skip to main content
Glama
lordbasilaiassistant-sudo

base-security-scanner-mcp

analyze_bytecode

Disassemble contract bytecode on Base mainnet to identify patterns like proxy, diamond, AMM, lending, and token standards for security analysis.

Instructions

Disassemble contract bytecode on Base mainnet and identify known patterns (proxy, diamond, AMM, lending, ERC-20, ERC-721, etc).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesContract address on Base mainnet

Implementation Reference

  • The `analyze_bytecode` tool handler, which fetches contract bytecode and performs opcode analysis, selector extraction, and contract type identification.
    // Tool 4: analyze_bytecode
    server.tool(
      "analyze_bytecode",
      "Disassemble contract bytecode on Base mainnet and identify known patterns (proxy, diamond, AMM, lending, ERC-20, ERC-721, etc).",
      {
        address: z.string().describe("Contract address on Base mainnet"),
      },
      async ({ address }) => {
        try {
          const code = await getContractBytecode(address);
          if (code === "0x" || code.length <= 2) {
            return ok({ address, isContract: false, message: "Not a contract" });
          }
    
          const selectors = extractSelectors(code);
          const opcodes = analyzeOpcodes(code);
          const contractTypes = identifyContractType(selectors);
    
          // Map known selectors
          const knownFunctions: Array<{ selector: string; name: string; category: string }> = [];
          for (const sel of selectors) {
            if (KNOWN_SELECTORS[sel]) {
              knownFunctions.push({ selector: sel, name: KNOWN_SELECTORS[sel].name, category: KNOWN_SELECTORS[sel].risk });
            } else if (PATTERN_SELECTORS[sel]) {
              knownFunctions.push({ selector: sel, name: PATTERN_SELECTORS[sel], category: "pattern" });
            }
          }
    
          // Unknown selectors
          const unknownSelectors = selectors.filter(
            s => !KNOWN_SELECTORS[s] && !PATTERN_SELECTORS[s]
          );
    
          return ok({
            address,
            bytecodeSize: (code.length - 2) / 2,
            contractTypes,
            opcodeAnalysis: opcodes,
            knownFunctions,
            unknownSelectors: unknownSelectors.slice(0, 50), // cap output
            totalSelectors: selectors.length,
            knownCount: knownFunctions.length,
            unknownCount: unknownSelectors.length,
          });
        } catch (err) {
          return fail(`analyze_bytecode failed: ${err instanceof Error ? err.message : String(err)}`);
        }
      }
    );
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 of behavioral disclosure. It mentions disassembly and pattern identification but lacks details on permissions needed, rate limits, error handling, or what the output looks like (e.g., format, completeness). For a tool with no annotations, this is a significant gap in 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 a single, efficient sentence that front-loads the core action and scope, with no wasted words. It directly communicates the tool's purpose and capabilities without unnecessary elaboration.

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 (analyzing bytecode for patterns) and lack of annotations and output schema, the description is minimally adequate. It covers what the tool does but omits critical behavioral details like output format, limitations, or error cases. Without an output schema, the description should ideally hint at return values, which it does not.

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 'address' parameter clearly documented. The description adds no additional parameter semantics beyond what the schema provides, such as address format or validation rules. Baseline score of 3 is appropriate since the schema does the heavy lifting.

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 ('Disassemble contract bytecode') and resource ('on Base mainnet'), with explicit enumeration of the patterns it identifies (proxy, diamond, AMM, lending, ERC-20, ERC-721, etc). It distinguishes from siblings like 'compare_bytecode' or 'get_contract_info' by focusing on pattern detection rather than comparison or general info retrieval.

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 when you need to analyze bytecode for known patterns on Base mainnet, but it does not explicitly state when to use this tool versus alternatives like 'scan_contract' or 'audit_report'. No exclusions or prerequisites are mentioned, leaving the context somewhat open-ended.

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