Provides tools for analyzing Ethereum smart contracts, including proxy contract detection, AccessControl role discovery, and ownership chain analysis across multiple Ethereum networks (mainnet, Goerli, Sepolia).
Enables discovery and tracking of OpenZeppelin AccessControl roles from contract event logs, including role grants, revokes, admin changes, and support for well-known roles like DEFAULT_ADMIN_ROLE and MINTER_ROLE.
Supports querying and analyzing smart contracts deployed on Polygon network, including proxy admin discovery and role management analysis.
Token Info MCP Server
⚠️ DISCLAIMER: AI-Generated Code
This entire codebase was generated by AI (Claude) within approximately 2 hours as a proof-of-concept. While functional, it likely contains bugs, edge cases, and security issues that have not been thoroughly tested.
Use with caution and at your own risk. This code is intended for educational and experimental purposes only. Do not use in production environments without proper code review, testing, and security auditing.
A Model Context Protocol (MCP) server that provides comprehensive token smart contract information by integrating with blockchain tools and APIs. Built in Python following the official MCP documentation.
Features
🔍 Proxy Contract Analysis
Detect if a contract is a proxy using Foundry's
casttoolRetrieve proxy admin addresses for upgradeable contracts
Support for multiple proxy types (TransparentUpgradeableProxy, etc.)
🔐 AccessControl Role Discovery
Discover OpenZeppelin AccessControl roles from contract event logs
Track role grants, revokes, and admin changes
Support for well-known roles (DEFAULT_ADMIN_ROLE, MINTER_ROLE, etc.)
Query historical role assignments with block range filtering
🌐 Multi-Network Support
Ethereum Mainnet, Goerli, Sepolia
Custom RPC endpoints
Etherscan API integration for all supported networks
Prerequisites
Python 3.10+
Foundry - Install from getfoundry.sh
Etherscan API Key - Get from etherscan.io
Installation
Clone the repository
git clone <repository-url> cd token-info-mcpInstall dependencies
pip install -r requirements.txtSet up environment variables Create a
.envfile:# Required ETHERSCAN_API_KEY=your_etherscan_api_key_here # Default RPC URL (used for mainnet) DEFAULT_RPC_URL=https://eth.llamarpc.com # Optional: Network-specific RPC URLs MAINNET_RPC_URL=https://eth.llamarpc.com GOERLI_RPC_URL=https://eth-goerli.g.alchemy.com/v2/your-api-key SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/your-api-key POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/your-api-key ARBITRUM_RPC_URL=https://arb-mainnet.g.alchemy.com/v2/your-api-key # Rate limiting RATE_LIMIT_REQUESTS_PER_SECOND=5
Usage
Running the Server
Claude Desktop Integration
Install Claude Desktop from official website
Configure the MCP server in Claude Desktop:
Edit configuration file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{ "mcpServers": { "token-info": { "command": "python", "args": ["/absolute/path/to/token_info_server.py"] } } }Restart Claude Desktop to load the server
Available Tools
Once configured, Claude Desktop will have access to these tools:
1. get_proxy_admin
Get comprehensive proxy admin and ownership analysis for an upgradeable proxy contract.
Features:
Detects proxy admin address
Identifies if proxy admin is a ProxyAdmin contract
Discovers ultimate owner of ProxyAdmin contracts
Maps complete ownership chain
Example usage in Claude:
"What's the complete ownership structure for 0x259338656198eC7A76c729514D3CB45Dfbf768A1?"
"Analyze the proxy admin and ownership chain for 0xdAC17F958D2ee523a2206206994597C13D831ec7"
"Who ultimately controls the proxy at 0x1234... using RPC URL https://eth.llamarpc.com?"
"Show me the full ownership analysis for 0xABCD... on polygon network"
2. get_contract_roles
Discover AccessControl roles and their assignments for a contract.
Example usage in Claude:
"What roles are defined in contract 0x1234...?"
"Who has the MINTER_ROLE in contract 0xABCD...?"
"Show me all role assignments for contract 0x5678... from block 18000000 to latest"
API Reference
get_proxy_admin
Parameters:
contract_address: The contract address to checknetwork: Network name (mainnet, goerli, sepolia, polygon, arbitrum) or use 'custom' with rpc_urlrpc_url: Custom RPC URL to use (optional, overrides network setting)
Enhanced Response Format:
get_contract_roles
Parameters:
contract_address: The contract address to analyzenetwork: Network name (mainnet, goerli, sepolia, polygon, arbitrum)from_block: Starting block number (default: earliest)to_block: Ending block number (default: latest)
Returns:
Testing
There are several ways to test this MCP server:
1. Direct Testing
2. Claude Desktop Testing
Configure the server in Claude Desktop
Ask natural language questions about smart contracts
Look for the tools icon in Claude Desktop interface
3. Unit Testing
4. MCP Client Testing
Use an MCP client library to test the server programmatically:
Troubleshooting
Common Issues
"Cast command not found"
Install Foundry:
curl -L https://foundry.paradigm.xyz | bash && foundryup
"Etherscan API rate limit exceeded"
Get an Etherscan API key and set
ETHERSCAN_API_KEYReduce
RATE_LIMIT_REQUESTS_PER_SECOND
"Server not showing up in Claude Desktop"
Check the absolute path in configuration
Restart Claude Desktop
Check logs:
~/Library/Logs/Claude/mcp*.log
License
MIT License