Skip to main content
Glama

Hedera MCP Server

by hedera-dev

Hedera MCP 服务器

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

⚠️ 安全警告

**这是一个演示实现,不应在生产环境中使用。**当前实现存在多个安全漏洞:

  • 私钥在响应主体中发送
  • 敏感数据未加密
  • 没有交易验证机制

此实现旨在演示 MCP 概念,在用于生产环境之前应得到适当的保护。

主要目标

该 MCP 服务器的主要目的是演示 MCP 服务器如何处理交易的构建和执行,而客户端只需验证交易即可。具体来说:

  1. 交易构建完全在 MCP 服务器上进行
  2. 客户签署构建的交易
  3. MCP 服务器负责向 Hedera 网络提交交易
  4. 这种架构允许集中交易逻辑并降低客户端复杂性

先决条件

  • 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

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 网络进行交互,提供钱包创建、余额检查、交易构建和发送签名交易的工具。

  1. ⚠️ 安全警告
    1. 主要目标
      1. 先决条件
        1. 安装
          1. 构建应用程序
            1. 运行服务器
              1. 使用测试客户端进行测试
                1. 可用的 MCP 工具
                  1. 部署

                    Related MCP Servers

                    • A
                      security
                      A
                      license
                      A
                      quality
                      A Model Context Protocol server that gives LLMs the ability to interact with Ethereum networks, manage wallets, query blockchain data, and execute smart contract operations through a standardized interface.
                      Last updated -
                      31
                      1
                      8
                      TypeScript
                      MIT License
                    • -
                      security
                      A
                      license
                      -
                      quality
                      A Model Context Protocol server that enables interaction with Foundry tools through natural language, allowing users to create projects, build contracts, run tests, and manage Ethereum development environments.
                      Last updated -
                      1
                      Python
                      MIT License
                    • A
                      security
                      F
                      license
                      A
                      quality
                      A Model Context Protocol server implementation that provides endpoints for wallet-based authentication, cluster management, and name registration services.
                      Last updated -
                      TypeScript
                    • A
                      security
                      A
                      license
                      A
                      quality
                      A server that provides tools for interacting with MantraChain blockchain through the Model Context Protocol, allowing users to manage tokens, stake assets, query balances, and execute various blockchain operations.
                      Last updated -
                      18
                      1
                      2
                      TypeScript
                      MIT License

                    View all related MCP servers

                    MCP directory API

                    We provide all the information about MCP servers via our MCP API.

                    curl -X GET 'https://glama.ai/api/mcp/v1/servers/hedera-dev/hedera-mcp-server'

                    If you have feedback or need assistance with the MCP directory API, please join our Discord server