Provides RPC infrastructure to support multi-chain queries for token balances, transactions, and event logs across various blockchain networks.
Enables querying token balances and analyzing transaction data on the Binance Smart Chain (BSC).
Provides a suite of tools for querying native ETH, ERC20, and NFT balances, alongside transaction analysis and smart contract auditing on the Ethereum network.
Allows for querying onchain data, including token balances and transaction analysis, on the Optimism network.
Supports querying onchain data, token information, and transaction details on the Polygon network.
Provides basic onchain data querying capabilities for the Solana blockchain.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Onchain MCP ServerAudit this contract for security risks: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Onchain MCP Server
A comprehensive Model Context Protocol (MCP) server that provides tools for querying onchain data across multiple blockchain networks. This server supports 12+ blockchain networks and provides tools for ETH balances, ERC20 token balances, NFT balances, transaction analysis, and contract auditing.
Features
🔗 Multi-Chain Support
Ethereum (Mainnet, Sepolia)
Polygon
Arbitrum
Optimism
BSC (Binance Smart Chain)
Avalanche
Base
Scroll
Blast
Hyperliquid
Plasma
🛠️ Available Tools
ETH Balance Tool - Get native token balances
ERC20 Balance Tool - Token balance queries
NFT Balance Tool - ERC721/ERC1155 NFT balances
Transaction Fetcher - Detailed transaction analysis with ERC-20 transfer detection
Logs Query Tool - Event log analysis
Token Metadata Tool - Token information and metadata
Contract Audit Tool - Comprehensive contract analysis and security auditing
📋 Available Prompts
Contract Security Audit - AI-powered security analysis
Quick Analysis - Fast contract overview
Deep Dive Analysis - Comprehensive contract examination
Installation
Clone the repository
git clone https://github.com/0xGval/onchain-mcp.git cd onchain-mcpCreate virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activateInstall dependencies
pip install -r requirements.txtConfigure API keys
cp config_example.py config.py # Edit config.py with your API keys
Configuration
Required API Keys
Alchemy API Key - For RPC endpoints
Etherscan API Key - For contract verification and source code
Environment Variables
Set your API keys as environment variables:
Or add them directly to config.py:
Usage
Running the Server
Using with Claude Desktop
To use this MCP server with Claude Desktop, you need to configure it in your Claude Desktop settings:
Open Claude Desktop Settings
Go to "Developers" tab
Add a new MCP server with these settings:
Replace the path with your actual server.py location
Add your API keys to the environment variables
Restart Claude Desktop
Using with Other MCP Clients
The server provides tools that can be used with MCP-compatible clients like Cursor, or other MCP clients. The server exposes these tools via the MCP protocol.
How to Use the Tools with Claude
Once configured, you can use the tools directly in your conversations with Claude:
Example Prompts:
"Get the ETH balance for address 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
"Check the USDC balance for this address: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
"Analyze this transaction: 0xe3769f745ff477de5853b7410e62d8c0c32ae4f87982928432562dfabe6440eb"
"Audit this contract: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
"Get the metadata for this token: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
Available Commands:
eth_balance_tool- Check ETH balanceserc20_balance_tool- Check token balancesnft_balance_tool- Check NFT holdingstx_get_tool- Analyze transactionscontract_audit_tool- Audit smart contractstoken_metadata_tool- Get token informationlogs_tool- Query blockchain events
Troubleshooting Claude Desktop
Common Issues:
Server not starting: Make sure Python is in your PATH and all dependencies are installed
API key errors: Verify your API keys are correct and have sufficient quota
Network errors: Check your internet connection and RPC endpoint availability
Permission errors: Ensure Claude Desktop has permission to run Python scripts
Debug Steps:
Test the server manually:
python server.pyCheck Claude Desktop logs for error messages
Verify the server path in your MCP configuration
Ensure all environment variables are set correctly
API Documentation
Tools
Tool | Description | Parameters |
| Get ETH balance |
|
| Get ERC20 token balance |
|
| Get NFT balance |
|
| Fetch transaction details |
|
| Query event logs |
|
| Get token metadata |
|
| Analyze contract |
|
Prompts
Prompt | Description | Parameters |
| Security audit analysis | Contract data |
| Quick contract overview | Contract data |
| Comprehensive analysis | Contract data |
Examples
Get ETH Balance
Get ERC20 Balance
Analyze Transaction
Contract Audit
Network Support
The server supports multiple blockchain networks with different capabilities:
Full Support: Ethereum, Polygon, Arbitrum, Optimism, BSC, Avalanche, Base, Scroll, Blast
Limited Support: Solana, Plasma (basic functionality)
Security
API keys are stored in environment variables
Rate limiting is implemented to prevent abuse
Input validation for all parameters
Error handling for network failures
Contributing
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For issues and questions, please open an issue on GitHub.