Token Info MCP Server
Provides comprehensive smart contract analysis for EVM tokens, including proxy contract detection, ownership chain discovery, and OpenZeppelin AccessControl role management across multiple blockchain networks.
README
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
casttool - Retrieve 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-mcp -
Install dependencies
pip install -r requirements.txt -
Set 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
python token_info_server.py
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.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{ "mcpServers": { "token-info": { "command": "python", "args": ["/absolute/path/to/token_info_server.py"] } } } - macOS:
-
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
get_proxy_admin(contract_address: str, network: str = "mainnet", rpc_url: str = None) -> str
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:
{
"contract_address": "0x...",
"network": "mainnet",
"is_proxy": true,
"proxy_admin": "0x...",
"proxy_type": "TransparentUpgradeableProxy",
"proxy_admin_owner": "0x...",
"is_proxy_admin_contract": true,
"ownership_chain": [
"0x... (proxy contract)",
"0x... (proxy admin contract)",
"0x... (ultimate owner)"
]
}
get_contract_roles
get_contract_roles(
contract_address: str,
network: str = "mainnet",
from_block: str = "earliest",
to_block: str = "latest"
) -> str
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:
{
"contract_address": "0x...",
"network": "mainnet",
"roles": [
{
"role_hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"role_name": "DEFAULT_ADMIN_ROLE",
"admin_role": "0x0000000000000000000000000000000000000000000000000000000000000000",
"members": ["0x..."],
"total_grants": 5,
"total_revokes": 1
}
],
"total_roles": 3,
"block_range": {
"from": "earliest",
"to": "latest"
}
}
Testing
There are several ways to test this MCP server:
1. Direct Testing
# Test the server directly
python token_info_server.py
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
# Install test dependencies
pip install pytest pytest-asyncio
# Run tests
pytest tests/
4. MCP Client Testing
Use an MCP client library to test the server programmatically:
import asyncio
from mcp.client import Client
async def test_server():
client = Client()
# Connect to server via stdio
# Call tools and verify responses
Troubleshooting
Common Issues
-
"Cast command not found"
- Install Foundry:
curl -L https://foundry.paradigm.xyz | bash && foundryup
- Install Foundry:
-
"Etherscan API rate limit exceeded"
- Get an Etherscan API key and set
ETHERSCAN_API_KEY - Reduce
RATE_LIMIT_REQUESTS_PER_SECOND
- Get an Etherscan API key and set
-
"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
Resources
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。