tron_mcp_server
MCP server for TRON blockchain integration, enabling AI assistants to check balances, manage transactions, interact with smart contracts, and access real-time blockchain data.
README
TRON MCP Server
A Model Context Protocol (MCP) server that provides seamless integration with the TRON blockchain, enabling AI assistants like Claude to interact with TRON network features including balance checking, transaction management, smart contract interaction, and real-time blockchain data.
🚀 Features
Core Blockchain Functions
- Balance Management: Check TRX and TRC20 token balances
- Transaction Operations: Send TRX and interact with smart contracts
- Resource Management: Monitor and manage energy and bandwidth
- Smart Contract Interaction: Call contract methods and estimate energy consumption
- Block Explorer: Query blocks, transactions, and contract information
Advanced Features
- Smart Fallback System: Automatic fallback to TronGrid/TronScan APIs when local node unavailable
- Energy Estimation: Accurate energy consumption predictions for transactions
- Price Tracking: Real-time TRX price and energy cost calculations
- Network Monitoring: Chain parameters and network statistics
- Documentation Search: Access TRON developer documentation
- Code Examples: Ready-to-use code snippets for common operations
🔄 Smart Fallback System
The MCP server now features an intelligent fallback system that automatically switches between data sources:
- Primary: Local TRON node (fastest, most reliable)
- Fallback 1: TronGrid API (official TRON Foundation API)
- Fallback 2: TronScan API (community explorer API)
Benefits:
- ✅ Works without local TRON node installation
- ✅ Automatic failover for maximum uptime
- ✅ Smart source selection based on availability
- ✅ Performance optimization with availability caching
Supported Functions with Fallback:
get_balance- TRX balance checkingget_account_resources- Energy/bandwidth resourcesget_transaction- Transaction detailsget_block- Block informationget_current_block_number- Latest block numberget_chain_parameters- Network parameterscontract_call- Smart contract interaction (read-only via TronGrid)send_trx- TRX transfers (via TronGrid broadcasting)
📋 Prerequisites
- Node.js 18 or higher
- npm or yarn package manager
- TRON wallet address (for balance queries)
- Private key (optional, only for sending transactions)
- TronGrid API key (optional, for higher rate limits)
🛠️ Installation
Quick Installation (Recommended)
- Clone the repository:
git clone https://github.com/Netts-official/tron_mcp_server.git
cd tron_mcp_server
- Run automated setup:
# For Linux/macOS
chmod +x setup.sh
./setup.sh
# For Windows (PowerShell)
.\setup.ps1
# Alternative: Use npm script
npm run install-claude
The setup script will:
- ✅ Check Node.js version (18+)
- ✅ Install npm dependencies
- ✅ Create .env from .env.example
- ✅ Configure Claude CLI (if installed)
- ✅ Configure Claude Desktop (if installed)
- ✅ Test server functionality
Manual Installation
If you prefer manual setup:
- Install dependencies:
npm install
- Configure environment variables:
cp .env.example .env
# Edit .env with your configuration
- Add to Claude CLI:
claude mcp add tron -s user -- node $(pwd)/src/index.js
- Test the installation:
npm test-server
⚙️ Configuration
Environment Variables
Create a .env file in the root directory:
# Network Configuration
NETWORK=mainnet
# TRON Node URLs
FULL_NODE_URL=https://api.trongrid.io
SOLIDITY_NODE_URL=https://api.trongrid.io
EVENT_SERVER_URL=https://api.trongrid.io
# Optional: TronGrid API Key
TRONGRID_API_KEY=your-api-key-here
# Optional: Private Key (for sending transactions)
# WARNING: Keep this secure!
PRIVATE_KEY=your-private-key-here
Using Custom Nodes
If you run your own TRON nodes:
FULL_NODE_URL=http://your-full-node:8090
SOLIDITY_NODE_URL=http://your-solidity-node:8091
EVENT_SERVER_URL=http://your-full-node:8090
🚀 Quick Start
After installation, restart Claude to use TRON features:
✅ If you used automated installation
The setup script already configured everything. Just restart Claude and try:
"What is the current TRX price?"
"Check balance for address TXxx..."
"Estimate energy for USDT transfer"
🔧 Manual Configuration (if needed)
Claude Desktop
Edit your configuration file at:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"tron": {
"command": "node",
"args": ["/absolute/path/to/tron_mcp_server/src/index.js"],
"env": {
"NETWORK": "mainnet",
"TRONGRID_API_KEY": "your-api-key"
}
}
}
}
Claude CLI
claude mcp add tron -s user -- node /absolute/path/to/src/index.js
Cursor IDE
Add to your Cursor settings.json:
{
"mcp.servers": {
"tron": {
"command": "node",
"args": ["/absolute/path/to/tron_mcp_server/src/index.js"]
}
}
}
📚 Available Tools
Balance & Account Tools
get_balance
Get TRX balance for an address
{
"address": "TRX_ADDRESS_HERE"
}
get_account_resources
Get bandwidth and energy resources
{
"address": "TRX_ADDRESS_HERE"
}
Smart Contract Tools
estimate_contract_energy
Estimate energy needed for contract execution
{
"contractAddress": "CONTRACT_ADDRESS",
"functionName": "transfer",
"parameters": ["TO_ADDRESS", 1000000]
}
get_contract_info
Get detailed contract information
{
"contractAddress": "CONTRACT_ADDRESS"
}
Blockchain Data Tools
get_transaction
Get transaction details
{
"txId": "TRANSACTION_ID"
}
get_block
Get block information
{
"block": "12345678" // block number or hash
}
get_current_block_number
Get current block number only (compact output)
{}
API Integration Tools
trongrid_api_call
Direct call to TronGrid API endpoint
{
"endpoint": "/wallet/getnowblock",
"method": "POST",
"data": {}
}
tronscan_api_call
Direct call to TronScan API endpoint
{
"endpoint": "/api/block",
"params": {"sort": "-number", "limit": 1}
}
get_trongrid_block
Get block information directly from TronGrid API
{
"blockNumber": 12345678,
"onlyNumber": true
}
get_trongrid_account
Get account information directly from TronGrid API
{
"address": "TRX_ADDRESS_HERE"
}
Market Data Tools
get_energy_prices
Get current energy prices and TRX/USD rate
{}
💡 Usage Examples
Example 1: Check TRX Balance
User: Check the TRX balance of TRX1234567890abcdefghijklmnop
Claude: I'll check the TRX balance for that address.
[Claude uses get_balance tool]
The address has a balance of 1,234.56 TRX (1,234,560,000 SUN).
Example 2: Estimate USDT Transfer Energy
User: How much energy do I need to transfer USDT to a new address?
Claude: I'll estimate the energy needed for a USDT transfer.
[Claude uses estimate_contract_energy tool]
For transferring USDT to a new address (that hasn't held USDT before),
you'll need approximately 130,285 energy. This accounts for the initial
storage allocation on the TRON network.
Example 3: Get Current Energy Prices
User: What's the current cost of energy on TRON?
Claude: Let me check the current energy prices.
[Claude uses get_energy_prices tool]
Current energy pricing:
- Energy Price: 420 SUN per unit
- In TRX: 0.00042 TRX per energy unit
- In USD: $0.000042 per energy unit (at TRX price of $0.10)
Example 4: Get Current Block Number
User: What's the current block number on TRON?
Claude: I'll get the current block number for you.
[Claude uses get_current_block_number tool]
Current block number: 67,891,234
Timestamp: 2024-01-15T10:30:45.123Z
Source: trongrid_api
Example 5: Direct TronGrid API Call
User: Use TronGrid API to get current block information
Claude: I'll make a direct call to the TronGrid API.
[Claude uses trongrid_api_call with endpoint "/wallet/getnowblock"]
Successfully retrieved current block data directly from TronGrid API:
- Block Number: 74,086,797
- Timestamp: 2024-01-15T10:30:45.123Z
- Transactions: 156
Example 6: TronScan API Query
User: Get latest account activity from TronScan for address TXxx...
Claude: I'll query TronScan API for account information.
[Claude uses tronscan_api_call with endpoint "/api/account"]
Account activity retrieved from TronScan:
- Balance: 1,234.56 TRX
- Latest transactions: 25
- Contract interactions: 12
🔧 Advanced Configuration
Multiple API Keys
For load balancing across multiple TronGrid API keys:
TRONGRID_API_KEY=key1,key2,key3
Caching
Enable caching for better performance:
ENABLE_CACHE=true
CACHE_TTL=300 # Cache time-to-live in seconds
Debug Mode
Enable detailed logging:
DEBUG=true
📖 Creating a CLAUDE.md File
For projects using this MCP server, create a CLAUDE.md file in your project root to help Claude understand how to use TRON features:
# TRON Integration Instructions
This project uses the TRON MCP server for blockchain interactions.
## Available TRON Operations
### Checking Balances
Use `get_balance` with any TRON address to check TRX balance.
### Energy Estimation
Use `estimate_contract_energy` before transactions to ensure sufficient energy.
### Smart Contract Interaction
Use `get_contract_info` to understand contract interfaces.
## Best Practices
1. Always estimate energy before sending transactions
2. Check account resources before complex operations
3. Use caching for frequently accessed data
🔄 Updating MCP Server
To update the TRON MCP server to the latest version:
-
Exit Claude (close the application or press Ctrl+C in terminal)
-
Navigate to project directory:
cd /path/to/your/mcp-tron-server-github
- Initialize Git if not already done:
# Only run if git is not initialized
git init
git remote add origin https://github.com/Netts-official/tron_mcp_server.git
- Pull latest changes:
git pull origin main
- Restart Claude:
claude
# or restart Claude Desktop application
Alternative quick update:
cd /path/to/your/mcp-tron-server-github && git pull origin main && claude
The MCP server will automatically use the updated code when Claude restarts.
🛡️ Security Best Practices
- Never commit private keys to version control
- Use environment variables for sensitive data
- Implement rate limiting in production
- Use read-only operations when possible
- Validate all addresses before operations
- Monitor API usage and costs
🐛 Troubleshooting
Server not starting
# Check Node.js version
node --version # Should be 18+
# Verify dependencies
npm install
# Check environment variables
node -e "console.log(require('dotenv').config())"
Connection issues
# Test TRON node connectivity
curl https://api.trongrid.io/wallet/getnowblock
# Check API key validity
curl -H "TRON-PRO-API-KEY: your-key" https://api.trongrid.io/wallet/getnowblock
Energy estimation errors
- Ensure contract address is valid
- Check if contract is verified on TronScan
- Verify function name and parameters match ABI
🤝 Contributing
Contributions are welcome! Please:
- 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.
🌟 Acknowledgments
- TRON Foundation for blockchain infrastructure
- Anthropic for the MCP protocol
- TronWeb for the JavaScript SDK
- Community contributors
📞 Support
- GitHub Issues: Report bugs or request features
- Documentation: TRON Developer Hub
- Community: TRON Discord
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。