Hedwig

Hedwig

An MCP wallet server that lets an AI agent hold, send, and spend USDC on Hedera, using the x402 standard for HTTP payments.

Category
访问服务器

README

<p align="center"> <a href="docs/hedwig_logo.png"> <img src="docs/hedwig_logo.png" alt="Hedwig" width="320" /> </a> </p>

<h1 align="center">Hedwig</h1>

<p align="center"> <strong>An MCP wallet that gives AI agents autonomous HBAR and USDC payments on Hedera through the x402 protocol</strong> </p>

<p align="center"> Payments travel over HTTP using the x402 standard, which means agents can pay for API calls or gated content the same way a browser handles a login prompt. Every settlement is a real HTS transfer, done in about three seconds, for a fixed fee under a hundredth of a cent. </p>

<p align="center"> <img src="https://img.shields.io/badge/x402-HTTP%20402%20payments-F5A0B1?style=flat-square" alt="x402" /> <img src="https://img.shields.io/badge/Hedera-settlement-1a1a1a?style=flat-square&labelColor=B06AB3" alt="Hedera" /> <img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" /> <img src="https://img.shields.io/badge/Node.js-%3E%3D%2018-339933?style=flat-square&logo=node.js&logoColor=white" alt="Node.js" /> <img src="https://img.shields.io/badge/protocol-MCP-B06AB3?style=flat-square" alt="MCP" /> <img src="https://img.shields.io/badge/license-MIT-green?style=flat-square" alt="License" /> </p>


Features

  • Native HBAR + USDC transfers on Hedera through Hedera Token Service, no bridges or wrapped assets. Charge either asset for x402 endpoints by toggling X402_ASSET.
  • x402 autopay with the full protocol loop: detect 402, sign payment, retry with proof, deliver content. Buyer pays no gas because the resource server acts as fee payer.
  • Budget caps enforced before every signature, both per-call and per-UTC-day, so a runaway agent cannot drain the account.
  • MCP native with seven JSON-RPC tools exposed over stdio, works with Claude Desktop, Cursor, Windsurf, and any MCP host.
  • Reliable balance queries via Hedera Mirror Node REST so cross-region traffic never times out on gRPC.
  • Full audit trail through the spending report tool: session totals, budget usage, and a rolling history of the last 25 payments.
  • Local x402 demo server included, so you can exercise the full flow on your own machine without any hosted dependency.
  • MetaMask-compatible ECDSA keys, use a single private key across web3 wallets and Hedwig without conversion.

Architecture

System architecture

x402 payment flow


Tools

Seven tools exposed to the agent over MCP. Every tool that moves money runs through the budget checker before it signs.

Tool What it does
check_balance Return HBAR and USDC balances plus a HashScan account link. Reads from Mirror Node REST for reliability.
transfer_hbar Send HBAR to any Hedera account. Real on-chain transfer, optional memo, HashScan link returned.
transfer_usdc Send USDC (HTS token 0.0.429274 on testnet) to another USDC-associated account.
pay Sign an x402 payment authorization without submitting anything. Useful when you want to drive the HTTP retry yourself.
x402_fetch Full protocol loop: fetch a URL, catch the 402, sign the payment, retry with the signature header, return the paid body.
spending_report Session totals, current budget usage, and a rolling history of the last 25 signed payments.
request_funding Return your account ID plus a link to the Hedera Portal faucet, for topping up testnet HBAR.

Quick start

Three lines and you have a wallet an agent can drive.

git clone https://github.com/DarshanKrishna-DK/Hedwig.git
cd Hedwig
run.bat        # Windows.  Or ./run.sh on macOS or Linux.

run.bat installs dependencies, compiles TypeScript, runs the unit test suite, submits a real on-chain smoke transaction (produces HashScan links), boots the MCP server on stdio, and opens the landing page site in a separate window. Leave both windows open. On first run it will pause and ask you to fill in .env with your Hedera testnet Account ID and ECDSA private key from portal.hedera.com/dashboard.

For the paid endpoint your agent will hit, open another terminal:

start-x402-server.bat                   # Windows
node examples/x402-server/server.mjs    # cross-platform

By default the demo server charges 0.001 HBAR per request. To switch to USDC, add X402_ASSET=usdc to .env and restart the server.

Wire Hedwig into Claude Desktop

Edit %APPDATA%\Claude\claude_desktop_config.json on Windows, or ~/Library/Application Support/Claude/claude_desktop_config.json on macOS. Add this block and restart Claude Desktop fully from the system tray.

{
  "mcpServers": {
    "hedwig": {
      "command": "node",
      "args": ["C:/path/to/Hedwig/dist/index.js"],
      "env": {
        "HEDERA_ACCOUNT_ID": "0.0.YOUR_ID",
        "HEDERA_PRIVATE_KEY": "YOUR_ECDSA_KEY",
        "NETWORK": "hedera-testnet",
        "MAX_PER_CALL": "0.10",
        "MAX_PER_DAY": "20.00"
      }
    }
  }
}

Open a new chat and check the plug icon in the bottom-left. You should see hedwig with seven tools.

Talk to your agent

> Check my Hedera balance.
> Send 0.05 HBAR to 0.0.9865777 with the memo "coffee tip".
> Send 0.001 USDC to 0.0.9865777.
> Fetch http://localhost:4021/premium/quote and pay if it costs HBAR.
> Fetch http://localhost:4021/premium/quote and pay if it costs USDC.
> Show me my spending report.

Live testnet transactions

Every link below is a real transaction on Hedera testnet, submitted through Hedwig during a live demo run.

Accounts. Buyer: 0.0.6886052. Auto-created x402 server: 0.0.9865777.

# What Asset On-chain proof
1 HBAR transfer (0.05 HBAR) HBAR native 0.0.6886052-1785556514-498454371
2 USDC transfer (0.001 USDC) HTS 0.0.429274 0.0.6886052-1785556535-966482234
3 x402 payment (first run) USDC 0.0.9865777-1785556125-503661238
4 x402 payment (repeat) USDC 0.0.9865777-1785556582-000507004

Rows 3 and 4 are the heart of the project. Agent hit 402, signed a payment on its own, retried with the payment signature header, and only got content after settlement reached consensus. No wallet popup, no manual approval, no bridge. Notice both transaction IDs start with the server account rather than the buyer, which proves gasless UX: the resource server pays HBAR gas as facilitator while the buyer only signs the transfer authorization.


Repo layout

Path Role
src/ MCP server: seven tools, config, Hedera helpers, spending tracker
__tests__/ Vitest unit tests for spending, config, and Hedera helpers
examples/x402-server/ Local x402 paid endpoint, auto-creates its own Hedera account
projects/Hedwig-frontend/ React site with landing page and docs (Vite + Tailwind + Framer Motion)
docs/ Architecture diagrams as SVG
scripts/smoke.mjs End-to-end on-chain smoke test that produces HashScan links
DEMO.md Beat-by-beat script for the demo video recording

Scripts

Command Purpose
run.bat / ./run.sh Full end-to-end. Install, build, test, smoke, launch MCP + landing site.
run-frontend.bat / ./run-frontend.sh Landing page + docs site only, on port 5173.
start-x402-server.bat Boot the local paid endpoint on port 4021.
smoke.bat Fast re-run of the on-chain smoke test only.
npm run build Compile the MCP server TypeScript to dist/.
npm test Run the 10 unit tests.
npm run smoke On-chain smoke test producing HashScan links.
npm run build:mcpb Package as an .mcpb bundle for one-click Claude Desktop install.

Network: Hedera testnet. HBAR asset id in x402: 0.0.0. USDC HTS token id: 0.0.429274 (testnet). HashScan: https://hashscan.io/testnet.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选