Skip to main content
Glama
lordbasilaiassistant-sudo

base-security-scanner-mcp

scan_contract

Analyze smart contracts on Base mainnet to detect security vulnerabilities including reentrancy patterns, access control issues, hidden mints, proxy patterns, and dangerous opcodes.

Instructions

Analyze a smart contract on Base mainnet for security issues including reentrancy patterns, access control, hidden mints, proxy patterns, and dangerous opcodes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesContract address on Base mainnet

Implementation Reference

  • The handler implementation for the "scan_contract" tool. It fetches bytecode, extracts function selectors, analyzes opcodes, identifies contract types, checks ownership, and performs various security checks based on the extracted information.
    server.tool(
      "scan_contract",
      "Analyze a smart contract on Base mainnet for security issues including reentrancy patterns, access control, hidden mints, proxy patterns, and dangerous opcodes.",
      {
        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: "Address is not a contract (EOA or empty)" });
          }
    
          const selectors = extractSelectors(code);
          const { findings, riskCounts } = analyzeSelectorRisks(selectors);
          const opcodes = analyzeOpcodes(code);
          const contractTypes = identifyContractType(selectors);
          const ownership = await checkOwnership(address);
    
          const issues: Array<{ severity: string; issue: string; detail: string }> = [];
    
          // Reentrancy risk: delegatecall + external calls
          if (opcodes.hasDelegatecall) {
            issues.push({ severity: "high", issue: "DELEGATECALL present", detail: "Contract uses delegatecall which can execute arbitrary external code. Potential reentrancy or logic manipulation risk." });
          }
    
          // Selfdestruct
          if (opcodes.hasSelfDestruct) {
            issues.push({ severity: "critical", issue: "SELFDESTRUCT present", detail: "Contract can be destroyed. All funds and state will be lost permanently." });
          }
    
          // Access control issues
          if (ownership.hasOwner && !ownership.isRenounced) {
            const dangerousWithOwner = findings.filter(f => f.risk === "critical" || f.risk === "high");
            if (dangerousWithOwner.length > 0) {
              issues.push({
                severity: "high",
                issue: "Active owner with dangerous permissions",
                detail: `Owner (${ownership.owner}) can call: ${dangerousWithOwner.map(f => f.name).join(", ")}`,
              });
            }
          }
    
          // Hidden mint
          const hasMint = findings.some(f => f.selector === "40c10f19");
          if (hasMint) {
            issues.push({ severity: "critical", issue: "Mint function detected", detail: "Owner can mint unlimited tokens, diluting holders." });
          }
    
          // Proxy patterns
          const isProxy = contractTypes.includes("Proxy Contract");
          if (isProxy) {
            issues.push({ severity: "medium", issue: "Proxy contract", detail: "Contract logic can be upgraded. The code you see today may change tomorrow." });
          }
    
          // Token approval traps: check if there's approve but unusual patterns
          const hasApprove = findings.some(f => f.selector === "095ea7b3");
          const hasTransferFrom = findings.some(f => f.selector === "23b872dd");
          if (hasApprove && !hasTransferFrom) {
            issues.push({ severity: "medium", issue: "Approve without transferFrom", detail: "Contract has approve() but no transferFrom(). Unusual pattern — may trap approvals." });
          }
    
          // Trading control
          const hasTradingControl = findings.some(f => f.selector === "1a8145bb");
          if (hasTradingControl) {
            issues.push({ severity: "critical", issue: "Trading can be disabled", detail: "Owner can call setTradingActive(false) to prevent all trading." });
          }
    
          return ok({
            address,
            contractTypes,
            bytecodeSize: (code.length - 2) / 2,
            ownership: serializeBigInts(ownership) as Record<string, unknown>,
            opcodeAnalysis: opcodes,
            riskCounts,
            issues,
            knownFunctions: findings,
            totalSelectorsFound: selectors.length,
          });
        } catch (err) {
          return fail(`scan_contract 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. While it mentions what the tool analyzes, it does not describe how it behaves—such as whether it requires authentication, has rate limits, returns structured results, or handles errors. For a security analysis tool with zero annotation coverage, this is a significant gap.

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 purpose and lists specific security issues without unnecessary words. Every part of the sentence contributes to understanding the tool's function, making it appropriately sized and well-structured.

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

Completeness2/5

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

Given the complexity of smart contract security analysis and the lack of annotations and output schema, the description is incomplete. It does not explain what the analysis returns (e.g., report format, severity levels), potential limitations, or prerequisites. For a tool with no structured output and zero annotation coverage, more detail is needed to guide effective use.

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 ('address') with its type and description. The description adds no additional parameter semantics beyond what the schema provides, such as format details or validation rules. Baseline 3 is appropriate when 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 ('Analyze a smart contract on Base mainnet') and enumerates the security issues it detects ('reentrancy patterns, access control, hidden mints, proxy patterns, and dangerous opcodes'). It distinguishes from siblings by focusing on comprehensive security scanning rather than specific aspects like bytecode analysis or honeypot detection.

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 security analysis of smart contracts on Base mainnet, but does not explicitly state when to use this tool versus alternatives like 'analyze_bytecode' or 'audit_report'. It provides context (smart contract security) but lacks explicit exclusions or comparisons with sibling tools.

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