Web3 MCP Server

by BaltasarAroso

97 downloads
Not rated
GitHub

Description

# Web3 MCP Server This project implements a Model Context Protocol (MCP) server that interacts with Ethereum networks using the [viem](https://viem.sh/) library. It supports querying balances, transactions, blocks, ENS, and more. ## Project Structure - **server/**: Main focus…

About

# Web3 MCP Server This project implements a Model Context Protocol (MCP) server that interacts with Ethereum networks using the [viem](https://viem.sh/) library. It supports querying balances, transactions, blocks, ENS, and more. ## Project Structure - **server/**: Main focus. Contains the MCP server implementation…

Details

Author
BaltasarAroso
Downloads
97
Categories
Other

- Get ETH and ERC-20 token balances
- Query transaction and block details
- ENS name resolution and reverse lookup
- Call read‑only contract methods
- Supports mainnet, Goerli, Sepolia, and local (Hardhat) networks

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Web3 MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install dependencies with npm install, optionally create a .env file to set CHAIN_ENV (defaults to mainnet), and start the server with npm start. You can switch networks at runtime by setting the CHAIN_ENV environment variable to mainnet, goerli, sepolia, or local. Use the mcp‑cli tool (npx @wong2/mcp-cli npm start) for interactive testing. For integration with Claude or Cursor IDE, build the server with npm run build and add a JSON MCP configuration pointing to the built index.js file.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "web3 mcp server": {
            "web3-mcp-server-baltasararoso": {
                "command": "npx",
                "args": [
                    "@wong2/mcp-cli",
                    "npm",
                    "start"
                ]
            }
        }
    }
}

McpServers

{
    "web3-mcp-server-baltasararoso": {
        "command": "npx",
        "args": [
            "@wong2/mcp-cli",
            "npm",
            "start"
        ]
    }
}

Web3 MCP Server

This project implements a Model Context Protocol (MCP) server that interacts with Ethereum networks using the viem library. It supports querying balances, transactions, blocks, ENS, and more.

Project Structure

- server/: Main focus. Contains the MCP server implementation and all core logic. So the commands and instructions below will assume its directory: cd server. - client/: Used for testing the MCP server. You can use this folder to run test scripts or interact with the server during development. To run the client run: cd client; npm i && npm start

Features

- Get ETH and ERC-20 token balances - Query transaction and block details - ENS name resolution and reverse lookup - Call read-only contract methods - Supports mainnet, Goerli, Sepolia, and local (Hardhat) networks

Environment Setup

1. Install dependencies:

   npm install

2. Create a .env file (optional, for environment variables):
   CHAIN_ENV=mainnet # or goerli, sepolia, local

- If not set, defaults to mainnet.
- For local, ensure a node is running at http://127.0.0.1:8545.

Running the Server

npm start

Switching Networks

Set the CHAIN_ENV environment variable to one of: - mainnet - goerli - sepolia - local

Example:

CHAIN_ENV=goerli npm start

Testing the MCP Server

You can test the MCP server using the mcp-cli tool:
npx @wong2/mcp-cli npm start

This allows you to list tools, call them, and inspect the server's capabilities interactively.

Integrating MCP Server with Claude and Cursor IDE

Both Claude and Cursor IDE allow you to add custom MCP servers via their settings. The process is nearly identical for both tools:

Steps to Add MCP Server

1. Build your MCP server:

   npm run build

This compiles the server to the server/build directory.

2. Open the settings in your tool:
- Cursor IDE: Go to Settings > MCP.
- Claude (Desktop): Go to Settings > Developer > Edit Config.

3. Add a new global MCP server:
- You can do this via the UI or by editing the JSON config file directly.
- Example JSON config:

     {
"mcpServers": {
"web3-tools": {
"command": "node",
"args": ["$GITHUB_REPO/server/build/index.js"]
}
}
}

Replace $GITHUB_REPO with the path to your local repository directory.

4. Save the config and restart/reload the tool if needed.

5. To update tools:
- Always run npm run build after making changes to your server code.
- You may need to manually refresh the tool or restart the MCP server for changes to take effect.

Note: The UI and config file locations may change as these tools evolve. Refer to their documentation for the latest details.

Next Steps

- [x] Add write (transaction) support for testnet/local - [x] Ensure comprehensive demonstration via unit and integration (e2e) tests using Vitest (npm test runs all tests) - [ ] Refactor code into modules for maintainability - [ ] Add basic rate limiting or warning about RPC usage
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.