Skip to main content
Glama
perpbrain-sdk

perpbrain-sdk

Official

PERPBRAIN SDK

PERPBRAIN/perpbrain-sdk MCP server

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

sdk/

@perpbrain/sdk: public info-endpoint reads, the book simulator, owner limits (conservative, standard, pro), the kill-switch latch, execution-cost breakdown, receipt verifier, and the SVG results card.

ts/mcp-server/

MCP JSON-RPC handler and stdio MCP server (perpbrain-mcp) for the read and simulation tools. It does not accept an order tool.

server.json

MCP Registry metadata for io.github.PERPBRAIN/perpbrain-sdk (npm, stdio, no secrets). Optional logo path: docs/assets.md.

glama.json

Glama listing maintainer file (claim ownership of the Glama listing).

Dockerfile

Slim Node image for Glama and other hosts; stdio entrypoint, non-root user.

examples/

Runnable TypeScript examples on recorded public data.

verify/web/

Browser receipt checker (WebCrypto SHA-256), the same check as the PERPBRAIN verify page.

fixtures/

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.mjs

To 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 mcp

To 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-result

Simulate under the Standard preset, then see a looser leverage blocked before a fill is recorded:

node --experimental-strip-types examples/guarded-simulate.ts

Drive 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.ts

MCP 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

markets

List perpetual markets from the public info endpoint.

order_book

Read a capped order book and its data age.

funding

Read funding, mark, and open interest for one coin.

positions

Read positions for one address.

fees

Read the address fee rates and their data age.

simulate

Simulate a closed-bar decision on a supplied book. Result is SIMULATED.

funding_extremes

Z-score of the public hourly funding rate against a trailing window.

book_imbalance

Bid depth divided by ask depth inside a public-book band.

get_limits

Read the owner limits and the remaining headroom.

trigger_kill_switch

Latch the kill switch. A tool call cannot clear it.

get_cost_breakdown

Recompute the execution-cost breakdown from a simulation receipt. The result is SIMULATED.

verify_receipt

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.json

CI 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 tools
book_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

    B3.2/5.0

    Scored across 12 tools

    Disambiguation4/5

    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.

    Naming Consistency3/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      MCP 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.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      A 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
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to interact with Hyperliquid perpetual futures exchange for market analysis, account management, and risk-managed trading.
      5
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      A 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.
      8
      2
      MIT