Onchain MCP Server
Provides tools for querying onchain data across 12+ blockchain networks, including token balances, transaction analysis, and smart contract security auditing. It enables users to interact with multiple EVM-compatible chains and perform deep contract evaluations through natural language interfaces.
README
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-mcp -
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install dependencies
pip install -r requirements.txt -
Configure 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:
export ETHERSCAN_API_KEY="your_etherscan_api_key"
Or add them directly to config.py:
"etherscan_api_key": "your_etherscan_api_key"
Usage
Running the Server
python server.py
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:
{
"mcpServers": {
"onchain-mcp": {
"command": "python",
"args": ["path/to/your/onchain-mcp/server.py"],
"env": {
"ETHERSCAN_API_KEY": "your_etherscan_api_key"
}
}
}
}
- 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.py - Check 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 |
|---|---|---|
eth_balance_tool |
Get ETH balance | address, network |
erc20_balance_tool |
Get ERC20 token balance | address, token_address, network |
nft_balance_tool |
Get NFT balance | address, nft_contract, token_id, network |
tx_get_tool |
Fetch transaction details | tx_hash, network |
logs_tool |
Query event logs | address, topics, from_block, to_block, network |
token_metadata_tool |
Get token metadata | address, network |
contract_audit_tool |
Analyze contract | address, network, format |
Prompts
| Prompt | Description | Parameters |
|---|---|---|
contract_security_audit_prompt |
Security audit analysis | Contract data |
contract_quick_analysis_prompt |
Quick contract overview | Contract data |
contract_deep_dive_prompt |
Comprehensive analysis | Contract data |
Examples
Get ETH Balance
result = eth_balance_tool("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "mainnet")
Get ERC20 Balance
result = erc20_balance_tool(
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"mainnet"
)
Analyze Transaction
result = tx_get_tool("0xe3769f745ff477de5853b7410e62d8c0c32ae4f87982928432562dfabe6440eb", "mainnet")
Contract Audit
result = contract_audit_tool("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "mainnet", "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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。