Skip to main content
Glama
RockYuan

MCP Smart Contract Analyst

by RockYuan

analyze-verified-contract

Analyze verified smart contracts on Monad testnet to assess functionality and security by providing a contract address.

Instructions

Analyze a verified contract from an address on the Monad testnet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesMonad testnet address to analyze verified contract for

Implementation Reference

  • The main handler function for the 'analyze-verified-contract' tool. It fetches verified source code from an API endpoint using the provided address, concatenates multiple source files if present, and returns a formatted text response for analysis, handling errors appropriately.
      async ({ address }) => {
        try {
          const apiUrl = process.env.API_URL
          const apiKey = process.env.API_KEY;
    
          if (!apiUrl) {
            throw new Error("API_URL not set.");
          }
    
          if (!apiKey) {
            throw new Error("API_KEY not set.");
          }
    
          const url = `${apiUrl}${address}`;
    
          const response = await fetch(url, {
            method: 'GET',
            headers: {
              "accept": "application/json",
              "x-api-key": apiKey
            }
          });
    
          if (!response.ok) {
            throw new Error(`API request failed with status ${response.status}`);
          }
    
          const data = await response.json();
    
          if (data.code !== 0) {
            throw new Error(`API request failed with error: ${data.message}`);
          }
    
          const sourceCodeList = data.result.sourceCode;
    
          if (sourceCodeList && sourceCodeList.length > 0) {
            const allSourceCode = sourceCodeList
              .map((item: { content: string }) => item.content)
              .join('\n\n');
    
            return {
              content: [
                {
                  type: "text",
                  text: `Analyze the source code of smart contract, including its core functionalities, main logic flow, and security aspects:\n\`\`\`\n${allSourceCode}\n\`\`\``,
                },
              ],
            };
          } else {
            throw new Error(`Failed to retrieve source code`);
          }
        } catch (error) {
          console.error("Error getting contract sourceCode:", error);
          return {
            content: [
              {
                type: "text",
                text: `Failed to retrieve contract sourceCode for address: ${address}. Error: ${error instanceof Error ? error.message : String(error)
                  }`,
              },
            ],
          };
        }
      }
    );
  • Input schema defined using Zod, requiring a 'address' string parameter describing the Monad testnet contract address.
    {
      address: z.string().describe("Monad testnet address to analyze verified contract for"),
    },
  • src/index.ts:31-32 (registration)
    Registration of the 'analyze-verified-contract' tool using server.tool(), including name, description, schema, and handler.
    server.tool(
      "analyze-verified-contract",
  • src/index.ts:28-28 (registration)
    Declaration of server capabilities, listing 'analyze-verified-contract' as a supported tool.
    capabilities: ["analyze-verified-contract", "analyze-unverified-contract"]

Tool Definition Quality

Score is being calculated. Check back soon.

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/RockYuan/mcp-contract-analyst'

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