Hedera MCP 服务器
用于与 Hedera 网络交互的模型上下文协议 (MCP) 服务器。该服务器提供用于创建 Hedera 钱包、查看账户余额、构建交易以及发送签名交易的工具。
⚠️ 安全警告
**这是一个演示实现,不应在生产环境中使用。**当前实现存在多个安全漏洞:
- 私钥在响应主体中发送
- 敏感数据未加密
- 没有交易验证机制
此实现旨在演示 MCP 概念,在用于生产环境之前应得到适当的保护。
主要目标
该 MCP 服务器的主要目的是演示 MCP 服务器如何处理交易的构建和执行,而客户端只需验证交易即可。具体来说:
- 交易构建完全在 MCP 服务器上进行
- 客户签署构建的交易
- MCP 服务器负责向 Hedera 网络提交交易
- 这种架构允许集中交易逻辑并降低客户端复杂性
先决条件
- Node.js(v18 或更高版本)
- npm 或 yarn
- Hedera 账户(用于测试网或主网)
安装
- 克隆此存储库:
- 安装依赖项:
- 使用您的 Hedera 凭据在根目录中创建一个
.env
文件:
构建应用程序
编译 TypeScript 代码:
对于使用自动重新编译的开发:
运行服务器
启动服务器:
该服务器将在http://localhost:3000 (或 .env 文件中指定的端口)上可用。
使用测试客户端进行测试
该存储库包含一个测试客户端脚本,用于演示如何连接到 MCP 服务器并使用其工具。该客户端提供了完整的端到端流程,演示了所有可用的工具。
运行测试客户端:
测试客户端将:
- 连接到 MCP 服务器
- 列出可用的工具
- 创建一个新的 Hedera 钱包(创建钱包工具)
- 检查新账户余额(检查余额工具)
- 建立一个交易,将账户的全部余额转移到操作员账户(build-transaction 工具)
- 使用 Hedera SDK 在客户端签署交易
- 将签名的交易提交到 Hedera 网络(发送交易工具)
- 显示交易结果
这展示了通过 MCP 服务器与 Hedera 网络交互的完整生命周期,从帐户创建到交易提交。
可用的 MCP 工具
该服务器提供以下工具:
- create-wallet :创建一个具有最低初始余额的新 Hedera 帐户
- 无需输入参数
- 返回账户ID、公钥、私钥
- check-balance :检查 Hedera 账户的余额
- 输入:
accountId
(字符串) - 返回 tinybars 中的账户余额
- 输入:
- build-transaction :构建转账交易(无需签名)
- 输入:
senderAccountId
(字符串)recipientAccountId
(字符串)amount
(数字,以小条为单位)
- 返回 base64 编码的交易
- 输入:
- send-transaction :向 Hedera 网络发送已签名的交易
- 输入:
signedTransaction
(字符串,base64编码) - 返回交易状态和ID
- 输入:
部署
包含一个简单的部署脚本:
确保首先使其可执行:
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
模型上下文协议服务器可与 Hedera 网络进行交互,提供钱包创建、余额检查、交易构建和发送签名交易的工具。
Related MCP Servers
- -securityAlicense-qualityA Model Context Protocol server that provides Claude with comprehensive access to Solana blockchain data via the Helius API, enabling operations like checking wallet balances, retrieving blockchain information, and interacting with tokens and NFTs.Last updated -112TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables Claude AI to interact with the Solana blockchain through a standardized interface, providing tools for transactions, account queries, and wallet management.Last updated -21979Apache 2.0
- AsecurityAlicenseAqualityA Model Context Protocol server that connects Claude to Heurist Mesh APIs, providing access to various blockchain and web3 tools including cryptocurrency data, token security, Twitter intelligence, and web search capabilities.Last updated -1742PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server providing utility tools for development and testing, offering functionalities like personalized greetings, random card drawing, and datetime formatting with an extensible architecture.Last updated -194642TypeScriptMIT License