perpbrain-sdk
OfficialA keyless, read-only MCP server for Hyperliquid data, simulation, and receipt verification—no order tools.
List perpetual markets and read capped order books with data age.
Read funding, mark price, and open interest for a coin.
Read positions and fee rates for an address.
Simulate a closed-bar decision on a supplied book (result labelled SIMULATED).
Compute Z-scores of hourly funding rates against a trailing window.
Measure book imbalance from bid/ask depth inside a public-book band.
Read owner limits and remaining headroom; latch a kill switch that tool calls cannot clear.
Recompute execution-cost breakdowns from simulation receipts (SIMULATED).
Verify simulation receipts against manifest and input bytes (VERIFIED or MISMATCH).
PERPBRAIN SDK
TypeScript SDK, MCP handler, examples, and receipt verifier for PERPBRAIN: read-only Hyperliquid data, a book simulator, and owner limits for AI agents. Simulation receipts are verified and reproducible: anyone can re-derive a receipt from its inputs and get the same hashes.
This repository has no mainnet order path, no exchange keys, and no publish workflow. Simulation output is labelled SIMULATED. See the risk disclosure.
The PERPBRAIN hosted service and engine are not in this repository. This repository is the public client surface.
What is here
Path | Role |
|
|
| MCP JSON-RPC handler and stdio MCP server ( |
| MCP Registry metadata for |
| Glama listing maintainer file (claim ownership of the Glama listing). |
| Slim Node image for Glama and other hosts; stdio entrypoint, non-root user. |
| Runnable TypeScript examples on recorded public data. |
| Browser receipt checker (WebCrypto SHA-256), the same check as the PERPBRAIN verify page. |
| Recorded public info responses and good and tampered receipt fixtures. No keys, no accounts. |
Related MCP server: hl-read
Requirements
Node 22+ is required (check with node -v). On Node 20 or older the examples and tests stop with node: bad option: --experimental-strip-types; upgrade Node to fix it. On Node 22 a harmless ExperimentalWarning: Type Stripping line is printed. No API key or other secret is needed for anything in this repository.
Install the MCP server
From a fresh clone:
git clone https://github.com/PERPBRAIN/perpbrain-sdk.git
cd perpbrain-sdk/ts/mcp-server && npm ci
cd ../..
node bin/perpbrain-mcp.mjsTo smoke-test it, pipe an initialize request followed by tools/list into the launcher; it should list the 12 tools below.
The launcher starts the stdio MCP server. Live reads use the public Hyperliquid /info endpoint (mainnet by default). Optional: set PERPBRAIN_HL_NETWORK=testnet for testnet.
Equivalent from the repository root after npm ci in ts/mcp-server/:
node bin/perpbrain-sdk.mjs mcpTo work on the TypeScript SDK itself (not required for MCP-only use):
(cd sdk && npm ci && npm run build)@perpbrain/sdk is 0.1.0-rc1 and marked private in package.json, so it is not on npm yet. npm run build writes ESM and CommonJS builds to sdk/dist.
Examples
Each example runs offline on the files in fixtures/.
Check a receipt. VERIFIED means every hash re-derived from the inputs matches. A tampered fixture prints MISMATCH and names the field.
node --experimental-strip-types examples/verify-receipt.ts fixtures/receipts/good
node --experimental-strip-types examples/verify-receipt.ts fixtures/receipts/tampered-resultSimulate under the Standard preset, then see a looser leverage blocked before a fill is recorded:
node --experimental-strip-types examples/guarded-simulate.tsDrive the MCP handler with recorded public data. The tool list is read and simulation only, and submit_order is refused:
node --experimental-strip-types examples/mcp-fixtures.tsMCP server (stdio)
The standalone MCP server uses the official @modelcontextprotocol/sdk over stdio. It is keyless: live reads use the public Hyperliquid /info endpoint only. Simulation uses the vendored book simulator. submit_order and other order tools are refused.
Simulation receipts are verified and reproducible. Owner limits are limits you set; losses are still possible.
Registry metadata lives in server.json (io.github.PERPBRAIN/perpbrain-sdk). For a step-by-step guide aimed at AI coding assistants (for example Cline), see llms-install.md.
MCP tools (12)
Registered tool names, in list order:
Tool | Purpose |
| List perpetual markets from the public info endpoint. |
| Read a capped order book and its data age. |
| Read funding, mark, and open interest for one coin. |
| Read positions for one address. |
| Read the address fee rates and their data age. |
| Simulate a closed-bar decision on a supplied book. Result is SIMULATED. |
| Z-score of the public hourly funding rate against a trailing window. |
| Bid depth divided by ask depth inside a public-book band. |
| Read the owner limits and the remaining headroom. |
| Latch the kill switch. A tool call cannot clear it. |
| Recompute the execution-cost breakdown from a simulation receipt. The result is SIMULATED. |
| Check a simulation receipt against manifest and inputs bytes. The check is verified and reproducible. |
Claude Desktop
Add a server block (no API keys). Use absolute paths on your machine:
{
"mcpServers": {
"perpbrain": {
"command": "node",
"args": ["/absolute/path/to/perpbrain-sdk/bin/perpbrain-mcp.mjs"],
"env": {
"PERPBRAIN_HL_NETWORK": "mainnet"
}
}
}
}Cursor
In Cursor Settings → MCP, add a server with the same shape (stdio, no secrets):
{
"mcpServers": {
"perpbrain": {
"command": "node",
"args": ["/absolute/path/to/perpbrain-sdk/bin/perpbrain-mcp.mjs"],
"env": {
"PERPBRAIN_HL_NETWORK": "mainnet"
}
}
}
}Replace /absolute/path/to/perpbrain-sdk with your clone path. Run cd ts/mcp-server && npm ci once before first use.
Receipt checker (browser)
Serve verify/web/ with any static server and drop the three receipt files on the page.
Using the SDK
import { GuardSession, guardedSimulate, verifyReceipt } from "@perpbrain/sdk";
const session = GuardSession.fromConfig("standard");
// guardedSimulate(...) records a fill only after the owner limits accept it.
// verifyReceipt(receipt, manifestBytes, inputsBytes) returns { status: "VERIFIED" | "MISMATCH", mismatches }.The read client only talks to the public /info endpoint, with an allowlist of request types. It refuses /exchange.
Owner limits
These are limits you set; losses are still possible. The owner picks a preset when a session starts. Standard is the default. Inside a session a caller can tighten a limit. A looser value is rejected. An MCP tool cannot set, raise, or clear a limit. Reducing or closing a position is never blocked. Details are in docs/guards.md.
Limit | Conservative | Standard (default) | Pro |
Max leverage, before the per-coin rule | 3x | 5x | 10x |
Per-order cap | Lesser of $10k and 20% of depth | Lesser of $25k and 20% of depth | Lesser of $250k and 20% of depth |
Daily stop | 3% | 5% | 10% |
Open positions | 3 | 5 | 15 |
Max slippage | 25 bps | 50 bps | 100 bps |
Order rate | 2/s | 5/s | 10/s |
Custom limits are capped at a 25% daily stop, 300 bps slippage, and 50 open positions.
Do not put exchange keys, wallets, or seed phrases in the environment, the repository, or a prompt. Nothing here reads them.
Checks
(cd ts/mcp-server && npm run lint && npm run typecheck && npm test)
(cd sdk && npm run typecheck && npm run build)
ts/mcp-server/node_modules/.bin/tsc -p examples/tsconfig.jsonCI runs the same checks plus a pinned gitleaks scan. CI uses no secrets.
Security and contributing
Report a vulnerability as described in SECURITY.md. Contribution rules are in CONTRIBUTING.md.
License
MIT. Copyright (c) 2026 GVNR DAO LLC. See LICENSE.
PerpBrain is an official project of GVNR DAO LLC, a Marshall Islands DAO LLC (registration number 10115-24). Simulation only, labelled SIMULATED; no live trading.
Available Tools
12 toolsbook_imbalanceC
Bid depth divided by ask depth inside a public-book band.
Inputs: no named parameters.
feesB
Read the address fee rates and their data age.
Inputs: no named parameters.
fundingB
Read funding, mark, and open interest for one coin.
Inputs: no named parameters.
funding_extremesB
Z-score of the public hourly funding rate against a trailing window.
Inputs: no named parameters.
get_cost_breakdownB
Recompute the execution-cost breakdown from a simulation receipt. The result is SIMULATED.
Inputs: no named parameters.
get_limitsB
Read the owner limits and the remaining headroom.
Inputs: no named parameters.
marketsA
List perpetual markets from the public info endpoint.
Inputs: no named parameters.
order_bookB
Read a capped order book and its data age.
Inputs: no named parameters.
positionsB
Read positions for one address.
Inputs: no named parameters.
simulateC
Simulate a closed-bar decision on a supplied book. Result is SIMULATED.
Inputs: no named parameters.
trigger_kill_switchB
Latch the kill switch. A tool call cannot clear it.
Inputs: no named parameters.
verify_receiptC
Check a simulation receipt against manifest and inputs bytes. The check is verified and reproducible.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools target clearly distinct reads (markets, order_book, positions, fees, get_limits) or distinct actions (simulate, trigger_kill_switch, verify_receipt). The main overlap risk is funding vs funding_extremes (raw read vs derived z-score) and order_book vs book_imbalance (raw book vs derived ratio), but the descriptions distinguish them well enough.
Conventions are mixed: bare nouns (markets, order_book, funding, positions, fees), noun+metric (funding_extremes, book_imbalance), get_-prefixed reads (get_limits, get_cost_breakdown), and imperative verbs (simulate, trigger_kill_switch, verify_receipt). Readable throughout, but there is no single predictable pattern.
12 tools is well-scoped for a perp/SDK surface covering market data, account reads, simulation, and risk controls. Each tool earns its place with no obvious redundancy.
Covers market data, account/position/fee/limit reads, simulation, cost breakdown, receipt verification, and a risk kill switch — a coherent analysis-and-simulation lifecycle. Gaps are minor and likely intentional (no order execution, and the kill switch is deliberately one-way with no clear/reset tool).
Maintenance
Related MCP Connectors
Non-custodial Hyperliquid perp trading: live markets, account state, user-armed order execution
Hyperliquid and Lighter market data: order books, trades, candles, funding, OI, and webhooks
Trade Papertrade BTC and ETH perps from Claude, ChatGPT, Codex, Cursor and any MCP client.
Hyperliquid MCP — read-only market data from Hyperliquid's public info API.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceMCP server for Hyperliquid perpetual DEX with 48 tools for trading, monitoring, risk management, and security. Enables real-time market data, order management, risk validation, and automated trading strategies.-
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server for Hyperliquid that provides public market data (prices, order books, funding) and any wallet's positions, orders, and fills via MCP tools, without requiring a private key.MIT
- AlicenseAqualityDmaintenanceEnables AI agents to interact with Hyperliquid perpetual futures exchange for market analysis, account management, and risk-managed trading.51MIT
- AlicenseAqualityDmaintenanceA read-only MCP server for querying Hyperliquid perp markets, funding rates, order books, candles, and account positions/fills/funding for any address, without needing API keys or wallets.82MIT