Mcp Pear

io.github.MarvelNwachukwu由 GitHub 帳號 MarvelNwachukwu 發布v0.2.2更新於 Oct 27, 2026

MCP server for Pear Protocol: markets, positions, orders, portfolio, and gated trade execution.

已驗證STDIO僅桌面金融資料與分析

概覽

AI 產生的概覽

供 Pear Protocol 在 Hyperliquid 上進行配對交易的 MCP 伺服器:瀏覽配對市場與比率、讀取持倉與投資組合,並可選擇執行交易。

可以做什麼
  • 瀏覽配對市場、熱門漲跌榜,以及指定配對的目前比率與資金費率
  • 讀取帳戶摘要、含損益的持倉、未成交的限價/止盈止損單、TWAP 訂單、成交歷史與分期間投資組合損益
  • 查看 Pear 用來簽署交易的代理錢包
  • 開啟交易執行後:開倉、平倉、全部平倉、調整部位大小或槓桿、設定止盈止損、取消訂單或 TWAP 訂單
  • 建立代理錢包
適用情境
適合讓助理研究 Pear 配對市場並追蹤既有帳戶,或在明確開啟寫入工具後,透過聊天用戶端在 Hyperliquid 上執行配對交易。
執行需求
透過 npx 從 npm 套件 @marvelcodes/mcp-pear 以 stdio 在本機執行(需 Node.js)。公開市場工具不需憑證。需驗證的工具需要 PEAR_API_KEY 與 PEAR_ADDRESS,或預先簽發的 PEAR_JWT(可搭配 PEAR_REFRESH_TOKEN)。寫入工具另需將 PEAR_TRADE_ENABLED 設為完全相符的 true。需要可連線 Pear API 的網路。
安裝前請注意
寫入工具會在 Hyperliquid 上執行真實交易,預設關閉;設定 PEAR_TRADE_ENABLED=true 後,助理可開倉、平倉、調整部位與取消掛單,槓桿最高 100 倍且有強制平倉風險。PEAR_API_KEY、PEAR_JWT 與 PEAR_REFRESH_TOKEN 是綁定錢包的機密。交易需 Hyperliquid 永續帳戶有資金並符合最小下單量。本專案為獨立社群封裝,與 Pear Protocol 無隸屬關係。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Mcp Pear,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

mcp-pear

[npm] [CI]

The Pear Protocol MCP server for Hyperliquid pair trading — connect Claude, Cursor, or any AI agent to on-chain perps: browse pair markets, read positions and portfolio, and (opt-in) execute pair trades.

Model Context Protocol (MCP) server for Pear Protocol. Gives Claude, or any MCP-compatible agent, access to markets, pair ratios, positions, orders, trade history, portfolio, and (v0.2) full trade execution on Hyperliquid.

v0.2 adds trade execution. Ten write tools (open, close, and adjust positions; manage leverage and risk; cancel orders) are off by default behind PEAR_TRADE_ENABLED=true. Pear signs server-side, so mcp-pear never holds private keys.

What is Pear Protocol?

Pear is a Hyperliquid-backed perps platform for pair markets: long one basket against another. Every pair has a live ratio that moves as the legs diverge. More at pearprotocol.io.

Tools

Public (no auth):

  • get_health: API health and uptime
  • list_markets: browse pair markets with filters and pagination
  • get_active_markets: top gainers, losers, and highlighted pairs
  • get_pair_ratio: current ratio, 24h change, and funding for a specific pair

Authenticated read:

  • get_account_summary: your account header
  • get_open_positions: your open positions with PnL
  • get_open_orders: your open limit, TP, and SL orders
  • get_twap_orders: your active TWAP orders
  • get_trade_history: your closed trades with realized PnL
  • get_portfolio: bucketed PnL across 1d, 1w, 1m, 1y, and all-time
  • get_agent_wallet: the agent wallet Pear uses to sign your trades

Authenticated write (v0.2, gated behind PEAR_TRADE_ENABLED=true):

  • create_agent_wallet: create the agent wallet
  • open_position, close_position, close_all_positions: open and close pair positions
  • adjust_position, adjust_leverage: change size or leverage on a live position
  • set_risk_parameters: set or update TP and SL
  • cancel_order, cancel_twap_order: cancel pending orders

Full parameter reference in Tool reference. See Trade execution (v0.2) for the gate and Hyperliquid funding rules.

Install

bash
# Run directlynpx -y @marvelcodes/mcp-pear@latest
# Or install globallypnpm install -g @marvelcodes/mcp-pearmcp-pear

Pin @latest (or a specific version) in the npx spec. Plain npx @marvelcodes/mcp-pear can launch a stale cached version: npx prefers its local cache over the npm registry when the spec is unpinned, so after a new release lands you may still be running the old one. @latest re-resolves against the registry each launch; pin like @0.2.0 instead if you want a frozen version. Stuck on an old version after upgrading? Clear the npx cache: rm -rf ~/.npm/_npx (macOS/Linux).

Getting an API key

For the authenticated tools, mint a key:

bash
npx -y @marvelcodes/mcp-pear@latest setup

The CLI opens a browser, asks you to sign once with your wallet, mints a Pear API key, and (optionally) writes PEAR_API_KEY and PEAR_ADDRESS to a .env. Copy those two values into your Claude Desktop config and restart Claude.

Already have a JWT from app.pear.garden? Skip setup and use JWT pass-through below.

Configuration

Three auth modes. mcp-pear uses the first one whose env vars are set, decided on the first authenticated call.

Mode 1: JWT pass-through (multi-tenant orchestrators)

For Telegram bots and other orchestrators that mint JWTs externally (Privy, EIP-712, or any Pear-supported flow). The JWT is opaque; mcp-pear never calls /auth/login.

Env varRequiredDescription
PEAR_JWTyesPre-minted access token. Used directly when set. PEAR_API_KEY and PEAR_ADDRESS act as fallback if the JWT expires and no PEAR_REFRESH_TOKEN is configured.
PEAR_REFRESH_TOKENnoIf set, mcp-pear refreshes the JWT itself when it expires mid-session (each refresh rotates the token). Without it, the orchestrator has to re-mint and respawn the subprocess.

When PEAR_JWT expires and no refresh token is set, authenticated tools return:

JWT expired; the orchestrator must mint a new one and restart mcp-pear.

See examples/telegram-bot-usage.ts for the orchestrator pattern.

Mode 2: API key + wallet address (single-user, Claude Desktop)

Env varRequiredDescription
PEAR_API_KEYfor auth toolsYour Pear API key.
PEAR_ADDRESSfor auth toolsWallet address bound to the API key (0x...).

mcp-pear mints the JWT itself by calling POST /auth/login. Both fields are required: the OpenAPI spec needs address in the request body.

Public-only mode

The four public tools work without any auth env vars. Authenticated tools return a ConfigError naming the missing env var.

Common settings (optional)

Env varDefaultDescription
PEAR_API_BASE_URLhttps://hl-v2.pearprotocol.ioPear API host.
PEAR_API_TIMEOUT_MS10000Per-request timeout.
PEAR_CLIENT_IDAPITRADERClient identifier sent to /auth/login.

Claude Desktop

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "pear": {      "command": "npx",      "args": ["-y", "@marvelcodes/mcp-pear@latest"],      "env": {        "PEAR_API_KEY": "your-pear-api-key-here",        "PEAR_ADDRESS": "0xYourWalletAddress"      }    }  }}

Restart Claude Desktop and ask: "Use Pear to show me the top active markets right now."

ADK-TS

ts
import { McpToolset, StdioTransport } from "@iqai/adk";
const pearTools = new McpToolset({	transport: new StdioTransport({		command: "npx",		args: ["-y", "@marvelcodes/mcp-pear@latest"],		env: { PEAR_API_KEY: process.env.PEAR_API_KEY ?? "", PEAR_ADDRESS: process.env.PEAR_ADDRESS ?? "" },	}),});
await pearTools.connect();const tools = await pearTools.listTools();

Full example in examples/adk-ts-usage.ts.

Tool reference

adjust_leverage

Change leverage (1-100x) on an existing Pear Protocol position. Higher leverage means greater liquidation risk for the same price move. WRITE: changes risk profile of a live position. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
positionIdstringyes
leverageintegeryes

adjust_position

Reduce or increase an existing Pear Protocol position's size by 1-100 percent. executionType: MARKET (immediate) or LIMIT (provide limitRatio). WRITE: changes exposure on a real trade. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
positionIdstringyes
adjustmentTypestringyes
adjustmentSizeintegeryes
executionTypestringyes
limitRationumber
referralCodestring

cancel_order

Cancel a pending Pear Protocol limit, take-profit, or stop-loss order by orderId. Does not affect already-filled portions. For TWAP orders, use cancel_twap_order. WRITE: cancels a live order. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
orderIdstringyes

cancel_twap_order

Cancel a Pear Protocol TWAP (time-weighted average price) order and all of its remaining unfilled chunks. WRITE: cancels a live order. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
orderIdstringyes

close_all_positions

Close every open Pear Protocol position with a single executionType (MARKET or TWAP). Returns a per-position result array with success/error. WRITE: executes real trades. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
executionTypestringyes
twapDurationnumber
twapIntervalSecondsnumber
randomizeExecutionboolean
referralCodestring

close_position

Close one open Pear Protocol position by positionId. executionType: MARKET (immediate) or TWAP (spread over time; requires twapDuration in seconds). WRITE: executes a real trade. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
positionIdstringyes
executionTypestringyes
twapDurationnumber
twapIntervalSecondsnumber
randomizeExecutionboolean
referralCodestring

create_agent_wallet

Create a new Pear Protocol agent wallet for the authenticated user. The agent wallet is what Pear uses to sign Hyperliquid trades. After creation, the user MUST approve this wallet on Hyperliquid (the response message contains the approval instructions). WRITE: executes a state change. Requires PEAR_TRADE_ENABLED=true.

No parameters

get_account_summary

Get the authenticated user's Pear Protocol account summary: agent wallet address, total closed trades, pending trigger-order USD value, pending TWAP-chunk USD value, and last sync timestamp. Requires PEAR_API_KEY.

No parameters

get_active_markets

Get the most active Pear Protocol pair markets right now: current active pairs plus top gainers, top losers, highlighted pairs, and the user's watchlist. Use to see what's hot or as a starting point for narrowing into a specific pair.

No parameters

get_agent_wallet

Get the authenticated user's Pear Protocol agent wallet address. The agent wallet is what Pear uses to sign Hyperliquid trades on the user's behalf. Returns an empty/missing address if no agent wallet has been created yet; call create_agent_wallet to create one.

No parameters

get_health

Check Pear Protocol API health. Returns service status, server timestamp, and uptime in seconds. Use this to verify the API is reachable before running other tools.

No parameters

get_open_orders

List the authenticated user's open limit, take-profit, and stop-loss orders on Pear Protocol. Returns each order's ID, type, status, and pair composition. Requires PEAR_API_KEY.

No parameters

get_open_positions

List the authenticated user's currently open Pear Protocol pair positions, including position ID, entry ratio, mark ratio, unrealized PnL, and long/short composition. Requires PEAR_API_KEY.

No parameters

get_pair_ratio

Get the current ratio (long/short composition price) for a specific Pear Protocol pair. Pass long and short asset arrays. Returns the ratio, 24h change, and funding rate. Useful when you know the pair you care about and want the latest number.

ParameterTypeRequiredDescription
longAssetsarrayyesAsset symbols on the long side (e.g. ['BTC']).
shortAssetsarrayyesAsset symbols on the short side. Pass an empty array for long-only baskets.

get_portfolio

Fetch the authenticated user's full portfolio metrics on Pear Protocol: bucketed PnL across last 1 day / 1 week / 1 month / 1 year / all-time, plus overall stats (total trades, all-time volume, current open interest, unrealized PnL). Requires PEAR_API_KEY.

No parameters

get_trade_history

Fetch the authenticated user's recent closed trades on Pear Protocol with realized PnL, entry/exit ratios, and pair composition. Optional date range and limit. Requires PEAR_API_KEY.

ParameterTypeRequiredDescription
limitintegerMax number of trades to return. Default 50.
startDatestringISO 8601 timestamp or epoch ms. Only return trades on or after this time.
endDatestringISO 8601 timestamp or epoch ms. Only return trades on or before this time.

get_twap_orders

List the authenticated user's active TWAP (time-weighted average price) orders on Pear Protocol, including chunk execution and fill detail. Requires PEAR_API_KEY.

No parameters

list_markets

Browse Pear Protocol pair markets with optional filters and pagination. Each market is a long/short composition with current ratio, 24h change, volume, open interest, and funding. Use to discover what's tradable, or with searchText to find a specific pair.

ParameterTypeRequiredDescription
searchstringFree-text search across market names (composition keys like `L:BTC
enginestringFilter by execution engine.
minVolumenumberMinimum 24h volume in USD.
change24hnumberMinimum 24h ratio change (e.g. 0.05 for +5%).
netFundingnumberFilter by net funding rate.
sortstringSort key (e.g. 'volume', 'change24h').
pageintegerPage number (1-indexed).
pageSizeintegerResults per page. Default 20.

open_position

Open a new pair position on Pear Protocol. Specify executionType (MARKET / TRIGGER / TWAP / LADDER / TP / SL / SYNC), leverage (1-100), usdValue (≥1), slippage (0.001-0.1), and the long/short asset compositions (arrays of { asset, weight }). Optionally attach stopLoss/takeProfit and TWAP/TRIGGER/LADDER parameters. WRITE: executes a real trade. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
executionTypestringyes
leverageintegeryes
usdValuenumberyes
slippagenumberyes
longAssetsarrayyes
shortAssetsarrayyes
triggerValuenumber
triggerTypestring
directionstring
twapDurationnumber
twapIntervalSecondsnumber
randomizeExecutionboolean
ladderConfigobject
stopLossunknown
takeProfitunknown
referralCodestring

set_risk_parameters

Set or update stop-loss / take-profit on an existing Pear Protocol position. Each threshold has type ('PRICE' or 'PERCENTAGE'), value, and optional trailing fields. Pass null to clear a field; omit it to leave unchanged. WRITE: changes risk parameters on a live position. Requires PEAR_TRADE_ENABLED=true.

ParameterTypeRequiredDescription
positionIdstringyes
stopLossunknown
takeProfitunknown

Development

bash
pnpm installpnpm run buildpnpm testpnpm run lintpnpm run format

Live smoke tests:

bash
PEAR_API_KEY=<real> pnpm test smoke

Trade execution (v0.2)

Ten new tools that take mcp-pear from read-only to write. All write tools are off by default. Set PEAR_TRADE_ENABLED=true to unlock them (strict literal match on "true"; anything else, including "True", "1", or "yes", keeps writes disabled). Pear signs trades server-side via an agent wallet you create, so mcp-pear never holds private keys for trades.

ToolTypeDescription
get_agent_walletreadGet the agent wallet Pear uses to sign your trades.
create_agent_walletwriteCreate one. After creation, approve it on Hyperliquid (the response message contains the instructions).
open_positionwriteOpen a pair position. Supports MARKET, TRIGGER, TWAP, LADDER, TP, SL, SYNC.
close_positionwriteClose one position by id (MARKET or TWAP).
close_all_positionswriteClose every open position with one execution type.
adjust_positionwriteReduce or increase position size by 1 to 100 percent. MARKET or LIMIT.
adjust_leveragewriteSet leverage 1 to 100x on an existing position. Carries liquidation risk.
set_risk_parameterswriteSet or update TP and SL on an existing position.
cancel_orderwriteCancel a pending limit, TP, or SL order.
cancel_twap_orderwriteCancel a TWAP order and its remaining chunks.
Env varDefaultDescription
PEAR_TRADE_ENABLEDunsetSet to "true" (lowercase, exact) to unlock the write tools. Anything else keeps them disabled and the gate error is returned to the LLM.

When PEAR_TRADE_ENABLED=true, mcp-pear logs [mcp-pear] PEAR_TRADE_ENABLED=true. Trade execution unlocked. to stderr on startup so operators can see writes are live.

Funding and minimums

Trades execute on Hyperliquid, which margins positions from your Perps balance. Two things bite first-time operators:

  • Minimum order size. Hyperliquid rejects orders below ~$10 notional. usdValue is the position's USD notional (margin = usdValue / leverage), so a single-leg position needs usdValue at or above 10. A long plus short pair is two separate orders, each subject to the $10 floor (about $20 or more notional total).
  • Spot vs Perps balance. USDC bridged onto Hyperliquid (for example via Circle CCTP) often lands in your Spot balance. Move it to Perps in the Hyperliquid app before trading, or open_position fails with insufficient margin.

What's next

v0.3. WebSocket streaming for real-time market and position updates. Spot orders. Candle synthesis from Hyperliquid candleSnapshot.

FAQ

What is the Pear Protocol MCP server? mcp-pear is a Model Context Protocol (MCP) server that gives Claude and other AI agents access to Pear Protocol — a Hyperliquid-backed platform for pair trading (long one basket against another). It exposes tools to browse pair markets and ratios, read positions, orders, and portfolio, and optionally execute pair trades.

How do I build a Pear Protocol trading agent? Point any MCP client at npx -y @marvelcodes/mcp-pear@latest. The agent gets read tools out of the box (markets, ratios, positions, portfolio). To let it trade, set PEAR_TRADE_ENABLED=true and add PEAR_API_KEY + PEAR_ADDRESS; it can then call open_position (MARKET / TRIGGER / TWAP / LADDER), close_position, adjust_leverage, and set_risk_parameters. See Claude Desktop and ADK-TS for wiring examples.

Does it support Hyperliquid pair trading? Yes. Pear runs on Hyperliquid, so every pair position is a long/short perp trade executed on Hyperliquid. mcp-pear covers the full lifecycle: open, adjust, set TP/SL, and close.

Is this the official Pear Protocol MCP server? No. mcp-pear is an independent, open-source community project that wraps Pear's public API. It is not affiliated with or endorsed by Pear Protocol.

Disclaimer

Not affiliated with Pear Protocol. Independent wrapper around Pear's public API. v0.2 trade-execution tools are off by default and require explicit operator opt-in (PEAR_TRADE_ENABLED=true). Pear signs server-side, so mcp-pear never holds private keys. Use at your own risk; no warranty.

License

MIT. See LICENSE.

來源:README.md,提交 9d837f5

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分