mcp otc

Local 2025-09-01 00:54:59 0

Fork from Etherscan dedicated for chain-id 175


An MCP (Model Context Protocol) server that provides Ethereum blockchain data tools via Etherscan's API. Features include checking ETH balances, viewing transaction history, tracking ERC20 transfers, fetching contract ABIs, monitoring gas prices, and resolving ENS names.

Features

  • Balance Checking: Get ETH balance for any Ethereum address
  • Transaction History: View recent transactions with detailed information
  • Token Transfers: Track ERC20 token transfers with token details
  • Contract ABI: Fetch smart contract ABIs for development
  • Gas Prices: Monitor current gas prices (Safe Low, Standard, Fast)
  • ENS Resolution: Resolve Ethereum addresses to ENS names

Prerequisites

  • Node.js >= 18
  • An Etherscan API key (get one at https://etherscan.io/apis)

Installation

  1. Clone the repository:

    git clone [your-repo-url]
    cd mcp-etherscan-server

  2. Install dependencies:

    npm install

  3. Create a .env file in the root directory:

    ETHERSCAN_API_KEY=your_api_key_here

  4. Build the project:

    npm run build

Running the Server

Start the server:

npm start

The server will run on stdio, making it compatible with MCP clients like Claude Desktop.

How It Works

This server implements the Model Context Protocol (MCP) to provide tools for interacting with Ethereum blockchain data through Etherscan's API. Each tool is exposed as an MCP endpoint that can be called by compatible clients.

Available Tools

  1. check-balance
  2. Input: Ethereum address
  3. Output: ETH balance in both Wei and ETH

  4. get-transactions

  5. Input: Ethereum address, optional limit
  6. Output: Recent transactions with timestamps, values, and addresses

  7. get-token-transfers

  8. Input: Ethereum address, optional limit
  9. Output: Recent ERC20 token transfers with token details

  10. get-contract-abi

  11. Input: Contract address
  12. Output: Contract ABI in JSON format

  13. get-gas-prices

  14. Input: None
  15. Output: Current gas prices in Gwei

  16. get-ens-name

  17. Input: Ethereum address
  18. Output: Associated ENS name if available

Using with Claude Desktop

To add this server to Claude Desktop:

  1. Start the server using npm start

  2. In Claude Desktop:

  3. Go to Settings
  4. Navigate to the MCP Servers section
  5. Click "Add Server"
  6. Enter the following configuration:
    {
      "name": "Etherscan Tools",
      "transport": "stdio",
      "command": "node /path/to/mcp-etherscan-server/build/index.js"
    }
  7. Save the configuration

  8. The Etherscan tools will now be available in your Claude conversations

Example Usage in Claude

You can use commands like:

Check the balance of 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
or
Show me recent transactions for vitalik.eth

Development

To add new features or modify existing ones:

  1. The main server logic is in src/server.ts
  2. Etherscan API interactions are handled in src/services/etherscanService.ts
  3. Build after changes: npm run build

License

MIT License - See LICENSE file for details

[
  {
    "description": "Check the ETH balance of an Ethereum address",
    "inputSchema": {
      "properties": {
        "address": {
          "description": "Ethereum address (0x format)",
          "pattern": "^0x[a-fA-F0-9]{40}$",
          "type": "string"
        }
      },
      "required": [
        "address"
      ],
      "type": "object"
    },
    "name": "check-balance"
  },
  {
    "description": "Get recent transactions for an Ethereum address",
    "inputSchema": {
      "properties": {
        "address": {
          "description": "Ethereum address (0x format)",
          "pattern": "^0x[a-fA-F0-9]{40}$",
          "type": "string"
        },
        "limit": {
          "description": "Number of transactions to return (max 100)",
          "maximum": 100,
          "minimum": 1,
          "type": "number"
        }
      },
      "required": [
        "address"
      ],
      "type": "object"
    },
    "name": "get-transactions"
  },
  {
    "description": "Get ERC20 token transfers for an Ethereum address",
    "inputSchema": {
      "properties": {
        "address": {
          "description": "Ethereum address (0x format)",
          "pattern": "^0x[a-fA-F0-9]{40}$",
          "type": "string"
        },
        "limit": {
          "description": "Number of transfers to return (max 100)",
          "maximum": 100,
          "minimum": 1,
          "type": "number"
        }
      },
      "required": [
        "address"
      ],
      "type": "object"
    },
    "name": "get-token-transfers"
  },
  {
    "description": "Get the ABI for a smart contract",
    "inputSchema": {
      "properties": {
        "address": {
          "description": "Contract address (0x format)",
          "pattern": "^0x[a-fA-F0-9]{40}$",
          "type": "string"
        }
      },
      "required": [
        "address"
      ],
      "type": "object"
    },
    "name": "get-contract-abi"
  },
  {
    "description": "Get current gas prices in Gwei",
    "inputSchema": {
      "properties": {},
      "type": "object"
    },
    "name": "get-gas-prices"
  },
  {
    "description": "Get the ENS name for an Ethereum address",
    "inputSchema": {
      "properties": {
        "address": {
          "description": "Ethereum address (0x format)",
          "pattern": "^0x[a-fA-F0-9]{40}$",
          "type": "string"
        }
      },
      "required": [
        "address"
      ],
      "type": "object"
    },
    "name": "get-ens-name"
  }
]