Skip to content

A unified TypeScript MCP (Model Context Protocol) server for multi-chain blockchain interactions, supporting Bitcoin, Ethereum, Base, and Optimism networks.

Notifications You must be signed in to change notification settings

hakmarkdev/blockchain-mcp

Repository files navigation

Blockchain MCP Server 1.0.0

A unified TypeScript MCP (Model Context Protocol) server for multi-chain blockchain interactions, supporting Bitcoin, Ethereum, Base, and Optimism networks.

Features

Multi-Chain Support

  • Bitcoin: Mainnet & Testnet (Blockstream API)
  • Ethereum: Mainnet & Sepolia (Alchemy, Infura, Public Nodes)
  • Base: Mainnet & Sepolia (L2)
  • Optimism: Mainnet & Sepolia (L2)

Core Capabilities

  • Wallet: Native & ERC20 token balances, UTXO analysis.
  • Transactions: Fetch details, decode raw txs, estimate gas/fees.
  • Network: Block details (latest or by hash), network stats, chain IDs.
  • Smart Contracts: Verify contract source, read state (via Viem).

Installation

# Install dependencies
npm install

# Build the project
npm run build

Configuration

The server is configured via environment variables. Create a .env file based on .env.example:

# Server Configuration
LOG_LEVEL=info

# API Keys (Recommended for stability)
ALCHEMY_API_KEY=your_alchemy_key
INFURA_API_KEY=your_infura_key
ETHERSCAN_API_KEY=your_etherscan_key
BASESCAN_API_KEY=your_basescan_key

# Custom RPC URLs (Optional overrides)
BITCOIN_RPC_URL=...
ETHEREUM_RPC_URL=...
BASE_RPC_URL=...
OPTIMISM_RPC_URL=...

# Custom Testnet RPC URLs (Optional overrides)
BITCOIN_TESTNET_RPC_URL=...
ETHEREUM_TESTNET_RPC_URL=...
BASE_TESTNET_RPC_URL=...
OPTIMISM_TESTNET_RPC_URL=...

Usage

Running the Server

Stdio Mode (default):

npm start

HTTP Mode:

npm run start:http

Available Tools

Bitcoin

  • bitcoin_get_balance: Get address balance.
  • bitcoin_get_utxos: List unspent transaction outputs.
  • bitcoin_analyze_utxos: Analyze UTXO set stats.
  • bitcoin_get_block: Fetch block by hash or height.
  • bitcoin_get_transaction: Fetch transaction by ID.
  • bitcoin_estimate_fee: Get current fee estimates.
  • bitcoin_decode_tx: Decode raw hex transaction.

Ethereum / L2s

  • eth_get_balance: Get native ETH balance.
  • eth_get_token_balance: Get ERC20 token balance.
  • eth_get_transaction: Get transaction details.
  • eth_get_transaction_status: Get transaction receipt status.
  • eth_get_block: Get block details (params: hash/number, includeTx).
  • eth_get_latest_block: Get the latest block.
  • eth_estimate_gas: Estimate gas for operations.
  • eth_get_address: Validate and normalize addresses.
  • eth_verify_contract: Check verification status (Explorer).
  • eth_get_network_info: Get gas price and chain stats.

MCP Client Configuration

Claude Desktop / Claude Code

Add the following to your claude_desktop_config.json (usually checking ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "blockchain-mcp": {
      "command": "node",
      "args": [
        "/absolute/path/to/blockchain-mcp/dist/index.js"
      ],
      "env": {
        "ALCHEMY_API_KEY": "your_key_here",
        "INFURA_API_KEY": "your_key_here"
      }
    }
  }
}

Cursor

  1. Open Cursor Settings > Features > MCP.
  2. Click Add New MCP Server.
  3. Enter the details:
    • Name: blockchain-mcp (or any name you prefer)
    • Type: stdio
    • Command: node /absolute/path/to/blockchain-mcp/dist/index.js
  4. Environment Variables:
    • You may need to create a wrapper script or use a .env loader if Cursor doesn't support direct env var entry in the UI yet, or ensure your global environment has the keys.
    • Alternatively, pass keys inline (not recommended for secrets) or configure the project to load from a specific .env path using dotenv in the code (which this project supports).

License

MIT

About

A unified TypeScript MCP (Model Context Protocol) server for multi-chain blockchain interactions, supporting Bitcoin, Ethereum, Base, and Optimism networks.

Topics

Resources

Stars

Watchers

Forks