Hedera MCP Server

Integrations

  • Enables interaction with the Hedera network, providing tools for creating Hedera wallets, checking account balances, building cryptocurrency transfer transactions, and sending signed transactions to the Hedera blockchain.

Hedera MCP 服务器

用于与 Hedera 网络交互的模型上下文协议 (MCP) 服务器。该服务器提供用于创建 Hedera 钱包、查看账户余额、构建交易以及发送签名交易的工具。

先决条件

  • Node.js(v18 或更高版本)
  • npm 或 yarn
  • Hedera 账户(用于测试网或主网)

安装

  1. 克隆此存储库:
    git clone https://github.com/hedera-dev/hedera-mcp-server.git cd hedera-mcp-server
  2. 安装依赖项:
    npm install
  3. 使用您的 Hedera 凭据在根目录中创建一个.env文件:
    HEDERA_OPERATOR_ID=your-operator-account-id HEDERA_OPERATOR_KEY=your-operator-private-key HEDERA_NETWORK=testnet # or mainnet PORT=3000 # optional, defaults to 3000

构建应用程序

编译 TypeScript 代码:

npm run build

对于使用自动重新编译的开发:

npm run dev

运行服务器

启动服务器:

npm start

该服务器将在http://localhost:3000 (或 .env 文件中指定的端口)上可用。

使用测试客户端进行测试

该存储库包含一个测试客户端脚本,用于演示如何连接到 MCP 服务器并使用其工具。该客户端提供了完整的端到端流程,演示了所有可用的工具。

运行测试客户端:

node test-client.js

测试客户端将:

  1. 连接到 MCP 服务器
  2. 列出可用的工具
  3. 创建一个新的 Hedera 钱包(创建钱包工具)
  4. 检查新账户余额(检查余额工具)
  5. 建立一个交易,将账户的全部余额转移到操作员账户(build-transaction 工具)
  6. 使用 Hedera SDK 在客户端签署交易
  7. 将签名的交易提交到 Hedera 网络(发送交易工具)
  8. 显示交易结果

这展示了通过 MCP 服务器与 Hedera 网络交互的完整生命周期,从帐户创建到交易提交。

可用的 MCP 工具

该服务器提供以下工具:

  1. create-wallet :创建一个具有最低初始余额的新 Hedera 帐户
    • 无需输入参数
    • 返回账户ID、公钥、私钥
  2. check-balance :检查 Hedera 账户的余额
    • 输入: accountId (字符串)
    • 返回 tinybars 中的账户余额
  3. build-transaction :构建转账交易(无需签名)
    • 输入:
      • senderAccountId (字符串)
      • recipientAccountId (字符串)
      • amount (数字,以小条为单位)
    • 返回 base64 编码的交易
  4. send-transaction :向 Hedera 网络发送已签名的交易
    • 输入: signedTransaction (字符串,base64编码)
    • 返回交易状态和ID

部署

包含一个简单的部署脚本:

./deploy.sh

确保首先使其可执行:

chmod +x deploy.sh
-
security - not tested
F
license - not found
-
quality - not tested

模型上下文协议服务器可与 Hedera 网络进行交互,提供钱包创建、余额检查、交易构建和发送签名交易的工具。

  1. Prerequisites
    1. Installation
      1. Building the Application
        1. Running the Server
          1. Testing with the Test Client
            1. Available MCP Tools
              1. Deployment
                ID: qt97pzp3ag