🌐 Plasma测试网MCP服务器v0.1
 ](https://nodejs.org)   ](https://www.docker.com)
Plasma测试网的生产就绪模型上下文协议(MCP)服务器
特性 • 快速开始 • API • 工具 • 例子 • 提示 • 安全
______________________________________________________________________
🚀 特性
🎯 完整的区块链集成
- 完整的Plasma网络测试网支持,具有原生XPL令牌操作
- 实时交易监控和状态跟踪
- 气体估算和优化,以实现经济高效的运营
- 多签名钱包支持(即将推出)
- 智能合约交互功能
- 全面的区块浏览器集成
🧠 智能交易引擎
- 天然气价格自动计算与优化
- 执行前的交易模拟
- Nonce管理和冲突解决
- 使用自动重试逻辑进行错误恢复
- 交易回执确认
- 实时网络状态监控
🤖 MCP协议实现
- 14+区块链自动化专用工具
- 与Claude Desktop和AI助手兼容
- HTTP和stdio传输支持
- 所有参数的Zod模式验证
- 全面的错误处理和记录
- 生产测试组件
🏛️ 企业就绪架构
- 使用Express.js构建可扩展性
- Ethers.js v5用于区块链交互
- 完全的TypeScript类型安全(通过Zod)
- Docker容器化支持
- 全面的日志记录和监控
- 基于环境的配置
______________________________________________________________________
📦 快速开始
✅ 先决条件
# Required
Node.js >= 18.0.0
npm >= 9.0.0
# Optional
Docker & Docker Compose (for containerized deployment)
Private key for transaction execution📥 安装
# Clone the repository
git clone https://github.com/tairon-ai/plasma-mcp.git
cd plasma-mcp
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your configuration
# Start the server
npm start
# Development mode
npm run dev
# MCP stdio server for Claude Desktop
npm run mcp🐳 Docker部署
# Build and run with Docker Compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down🤖 Claude桌面集成
添加到您的Claude Desktop配置中:
{
"mcpServers": {
"plasma-network": {
"command": "node",
"args": ["/path/to/plasma-mcp/mcp/index.js"],
"env": {
"RPC_URL": "https://testnet-rpc.plasma.to",
"WALLET_PRIVATE_KEY": "your_private_key_without_0x"
}
}
}
}______________________________________________________________________
🛠 可用工具
🏦 区块链运营
| 工具 | 说明 | 参数 |
|---|---|---|
getServiceInfo | 获取服务器功能和配置 | - |
getNetworkInfo | 获取Plasma网络信息 | - |
getAccountBalance | 获取地址的XPL余额 | address (可选) |
sendTransaction | 发送自定义交易 | to, value, data, gasLimit, gasPrice |
sendXPL | 发送XPL令牌 | to, amount |
getTransactionStatus | 检查交易状态 | txHash |
requestFaucet | 获取testnet水龙头信息 | address, faucetName |
estimateGas | 估算交易用气 | from, to, value, data |
getLatestBlocks | 获取最近的区块 | count |
getGasPrice | 获取当前天然气价格 | - |
getTokenInfo | 获取令牌详细信息 | tokenAddress |
getWalletBalances | 获取钱包代币余额 | walletAddress, tokens |
______________________________________________________________________
🔗 API终点
🌐 核心终点
GET / # Server status and info
GET /health # Health check
GET /info # Service information
GET /mcp # MCP server information
POST /mcp # MCP protocol endpoint______________________________________________________________________
💡 例子
💰 获取账户余额
// Get XPL balance
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "getAccountBalance",
"arguments": {
"address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb9"
}
},
"id": 1
}🔄 发送XPL代币
// Send 10 XPL to address
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "sendXPL",
"arguments": {
"to": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb9",
"amount": "10.0"
}
},
"id": 1
}📊 检查交易状态
// Check transaction by hash
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "getTransactionStatus",
"arguments": {
"txHash": "0x123...abc"
}
},
"id": 1
}______________________________________________________________________
🤖 提示
💬 Claude、ChatGPT或其他AI助手的示例提示
这些提示演示了如何在与AI助手集成时通过自然语言与MCP服务器交互:
💱 令牌操作
"What's my XPL balance?"
"Send 5 XPL to 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb9"
"Check the status of transaction 0x123...abc"
"Estimate gas for sending 100 XPL to this address"📊 网络分析
"Show me the current gas price on Plasma Network"
"Get the latest 5 blocks from the network"
"What's the current network status?"
"Show me network information including block height"💼 钱包管理
"Get my wallet nonce and balance"
"Show all token balances in my wallet"
"Request testnet XPL from the faucet"
"Calculate the cost of a transaction with current gas prices"🔧 智能合约交互
"Get information about token at address 0x..."
"Send a custom transaction with data payload"
"Estimate gas for a contract interaction"
"Check if a transaction was successful"🔧 AI助手的集成技巧
在MCP服务器上使用这些提示时:
- 始终指定地址 完整格式(0x…)
- 使用十进制金额 对于XPL(例如,“10.5”而不是“10500000000000000000”)
- 查看汽油价格 大型交易前
- 核实余额 在尝试转账之前
- 监控交易状态 发送后
______________________________________________________________________
🧪 测试
🔍 使用cURL进行API测试
# Check server health
curl http://localhost:8080/health
# Get MCP server info
curl http://localhost:8080/mcp
# Get service information
curl http://localhost:8080/info
# Execute a tool
curl -X POST http://localhost:8080/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "getNetworkInfo",
"arguments": {}
},
"id": 1
}'______________________________________________________________________
🔒 安全
🔐 最佳实践
- 私钥管理:永远不要提交私钥。使用环境变量
- 交易验证:所有参数都使用Zod模式进行验证
- 气体限制:具有安全裕度的自动气体估算
- 错误处理:对所有操作进行全面的错误处理
- 访问控制:为生产部署实施身份验证
- 监控:使用区块浏览器跟踪所有交易
🛡️ 安全功能
- 对所有输入进行Zod模式验证
- 带缓冲器的自动气体估算
- 交易模拟能力
- 私钥加密支持
- 速率限制就绪
- 全面的审计日志记录
______________________________________________________________________
📊 支持的网络和代币
🌐 网络
- 等离子体测试网 (链ID:9746)
- RPC:
https://testnet-rpc.plasma.to - 浏览器: 等离子探测器
🪙 本地令牌
- 炸药:原生Plasma网络令牌
- 小数:18
- 用于汽油费和转账
📜 未来合同(待部署)
- DEX路由器:去中心化交换路由
- 代币工厂:ERC20代币部署
- 流动性池:自动化做市
______________________________________________________________________
🚀 部署
🏭 生产部署
# Build for production
npm run build
# Start production server
NODE_ENV=production npm start
# With PM2
pm2 start server.js --name plasma-mcp
# With Docker
docker build -t plasma-mcp .
docker run -d -p 8080:8080 --env-file .env plasma-mcp🔑 环境变量
# Required for transactions
WALLET_PRIVATE_KEY=your_private_key_without_0x
# Network configuration
RPC_URL=https://testnet-rpc.plasma.to
# Optional
PORT=8080
NODE_ENV=production______________________________________________________________________
📈 演出
- 响应时间:读取操作小于100ms
- 交易速度:等离子网络上约2-5s
- 吞吐量:每秒100+个请求
- 气体优化:自动计算天然气价格
- 缓存:针对重复查询进行了优化
______________________________________________________________________
🤝 贡献
我们欢迎捐款!请查看我们的 贡献指南 了解详情。
# Fork and clone
git fork https://github.com/tairon-ai/plasma-mcp
git clone https://github.com/tairon-ai/plasma-mcp
# Create feature branch
git checkout -b feature/amazing-feature
# Make changes and test
npm test
# Commit and push
git commit -m 'feat: add amazing feature'
git push origin feature/amazing-feature
# Open Pull Request______________________________________________________________________
📄 许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
______________________________________________________________________
🙏 致谢
______________________________________________________________________
