Magpie Mcp

io.github.magpiecapital由 GitHub 帳號 magpiecapital 發布v0.1.1更新於 Oct 24, 2026

Agent-native lending on Solana via x402: borrow against tokens, arm in-vault TP/SL, repay.

已驗證STDIO僅桌面金融開發者工具

概覽

AI 產生的概覽

一個本機 MCP 伺服器,包裝 Magpie Capital 在 Solana 上的 x402 借貸 API,讓助理查詢貸款資料、模擬借款、建構交易並設定停利停損。

可以做什麼
查詢協議狀態:資金池狀態、24 小時彙總、近期活動、等級、資金池、抵押品目錄與可清算貸款,以及依 ID 或 PDA 查詢單筆貸款、錢包貸款與 LP 部位。模擬與評分:不送出地報價借款,取得信用分數與信用排行榜,以及單一代幣風險概況。建構交易:產生借款、還款、存款、提款與清算的未簽署交易供使用者簽署。管理條件借款意圖:建立並輪詢。設定與管理金庫內出場:對使用者自有貸款設定停利、停損與追蹤委託,並可列出、修改與取消。
適用情境
適合需要研究或操作 Magpie Solana 借貸協議的助理:檢視資金池健康度與貸款狀態、報價借款,或準備存款、還款與清算交易。也適合助理為使用者自有貸款設定或稽核停利停損委託。
執行需求
透過 npx 或原始碼建置以 stdio 在本機執行,需要 Node.js。選用環境變數:MAGPIE_MCP_PAYER_KEYPAIR(Solana 金鑰對 JSON 路徑,付費與出場工具必需)、SOLANA_RPC_URL(預設為公用主網 RPC)與 MAGPIE_X402_BASE_URL。需要連線至 x402 端點與 Solana RPC 的網路。
安裝前請注意
付費工具每次呼叫會從設定的付款金鑰對花費 SOL(0.0005 至 0.01 SOL),伺服器會用該金鑰對在本機簽署 x402 付款交易。出場工具也用同一金鑰對簽署信封,因此只應存入小額餘額。寫入路徑回傳未簽署交易,需使用者自行檢視並簽署。出場委託是經滑價機制執行的自動賣出委託,不保證成交。README 提到協議費用會流入代幣持有者獎勵池。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

magpie-mcp

Solana lending protocol — liquidity without selling your bag.

Borrow SOL against your memecoins, tokenized stocks, and RWAs — and set take-profits and stops on that same collateral. Liquidity now, upside intact: collateral that can still sell itself.

MCP server exposing the Magpie Capital x402 API as native tools for Claude Desktop, Cursor, Windsurf, ChatGPT desktop, and any other MCP-aware agent host.

Take-profit, stop-loss, ladders, trailing stops — they fire on-chain into your loan's vault, the loan stays open, and proceeds reach your wallet only when you repay. Auto-sell exits are V4 in-vault orders on supported collateral (memecoins + tokenized stocks/RWAs); they are auto-sell orders that fire on-chain through a slippage stack, not guaranteed fills.

Drop one config block into your host and your agent can query Magpie's protocol state, simulate borrows, fetch credit scores, build deposit/withdraw transactions, post conditional borrow intents, and arm self-owned in-vault take-profit / stop-loss exits on its own loans — all as first-class tool calls. No bespoke client code, no API keys.

A share of Magpie protocol fees accrues to a $MAGPIE holder-rewards pool, paid pro-rata in SOL (no staking, no lockup). 70% is the governance-ratified (MGP-001) target allocation; distributions run on a governance cadence. x402 call fees feed the same holder-rewards economics — agent adoption grows the fees that reward holders.

What it exposes

26 tools wrapping the x402 endpoints:

Free reads (work out of the box):

  • magpie_pool_state — live LendingPool account
  • magpie_protocol_pulse — 24h aggregates (active loans, volume, liquidations)
  • magpie_recent_activity — anonymized borrow/repay/liquidate stream
  • magpie_loan — single loan by ID
  • magpie_wallet_loans — all loans for a wallet
  • magpie_tiers — protocol tier constants
  • magpie_simulate_borrow — quote a loan without submitting
  • magpie_collateral_eligible — full collateral catalog
  • magpie_liquidatable — loans currently liquidatable
  • magpie_credit_leaderboard — top wallets by credit score
  • magpie_lp_state — depositor position + pool context
  • magpie_loan_by_pda — single loan by on-chain loan PDA
  • magpie_pools — Magpie lending pools (program-version lanes + context)
  • magpie_list_exits — armed in-vault exit orders for a wallet
  • magpie_modify_exit — change an armed exit's trigger / params
  • magpie_cancel_exit — cancel an armed exit (loan stays Active)

Paid (require a configured Solana keypair):

  • magpie_credit_score — 0.001 SOL
  • magpie_token_risk — 0.001 SOL (per-token risk profile)
  • magpie_build_borrow — 0.005 SOL (pass has_exit_arming: true to route into the V4 in-vault-exit lane)
  • magpie_build_repay — 0.002 SOL
  • magpie_build_deposit — 0.002 SOL
  • magpie_build_withdraw — 0.002 SOL
  • magpie_build_liquidate — 0.003 SOL (liquidate a past-due loan, receive keeper bounty)
  • magpie_create_intent — 0.01 SOL (conditional borrow)
  • magpie_get_intent — 0.0005 SOL (poll)
  • magpie_arm_exit — 0.001 SOL (arm a self-owned in-vault TP / SL / trailing exit)

When a paid tool fires, the server signs an x402 payment tx locally with your configured keypair and forwards the signature to magpie-x402. The keypair never leaves your machine.

Self-owned in-vault exits (V4)

Magpie's V4 lane lets an agent arm its own take-profit, stop-loss, and trailing exits on its own active loan — and the sell happens in-vault: when a trigger fires, the collateral is auto-sold and the proceeds (SOL by default, or USDC) accumulate inside that loan's per-loan proceeds vault while the loan stays Active. Proceeds only ever reach your wallet through your own borrower-signed repay. There's no fire-and-close, and nothing the protocol can do to move your funds out.

  • magpie_arm_exit (0.001 SOL) — arm a TP / SL / trailing exit on a V4 loan you own. Set direction (above = take-profit, the default; below = stop-loss) and exactly one trigger: target (e.g. "2x" / "0.7x"), price_usd, mc_usd (e.g. "5M", "1.2B"), or trailing_bps (stop-loss only). Optional slippage_bps, dest (sol | usdc), and slice for laddered exits.
  • magpie_modify_exit (free) — retune an armed order's trigger or params in place.
  • magpie_cancel_exit (free) — remove an armed order; the loan is untouched.
  • magpie_list_exits (free) — audit a wallet's armed orders, each with its distance-to-trigger.

Every exit call is authenticated with a dependency-free Ed25519 signed envelope built locally from your configured keypair. For magpie_arm_exit the envelope is signed by the same keypair that pays the 0.001 SOL x402 challenge, so the bot's payer == signer invariant holds and only the owner of a loan can arm exits on it. The bot enforces a 5-minute freshness window and nonce-uniqueness on every envelope.

To start a borrow that supports these exits, call magpie_build_borrow with has_exit_arming: true (routes into V4); leave it false for a plain memecoin (V1) borrow.

RWA / xStock collateral runs on the separate V3 lane, which is launch-gated — on the V3 launch, the same exit tooling will extend to RWA loans.

Install

Two paths. Both end at the same place.

Path A — npm (recommended once published)

No clone, no build, no absolute paths in your host config:

bash
# Verify it runs once before wiring into your host:npx -y @magpieloans/magpie-mcp --help

Then in your host config:

json
{  "mcpServers": {    "magpie": {      "command": "npx",      "args": ["-y", "@magpieloans/magpie-mcp"],      "env": {        "SOLANA_RPC_URL": "https://api.mainnet-beta.solana.com",        "MAGPIE_MCP_PAYER_KEYPAIR": "/path/to/payer-id.json"      }    }  }}

Path B — from source

If the npm package isn't published yet, or you want to hack on the server:

bash
git clone [email protected]:magpiecapital/magpie-x402.gitcd magpie-x402/mcpnpm installnpm run build

Built executable lands at mcp/dist/index.js. Use the absolute path in your host config below.

Configure your host

Pick the snippet for your host. The command + args shape changes between npm-install vs source-build; the env block is identical.

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

json
{  "mcpServers": {    "magpie": {      "command": "node",      "args": ["/ABS/PATH/TO/magpie-x402/mcp/dist/index.js"],      "env": {        "SOLANA_RPC_URL": "https://api.mainnet-beta.solana.com",        "MAGPIE_MCP_PAYER_KEYPAIR": "/ABS/PATH/TO/payer-id.json"      }    }  }}

Restart Claude Desktop. The Magpie tools appear in the tool picker.

Cursor

Edit ~/.cursor/mcp.json. Same shape as Claude Desktop above.

Windsurf

Edit ~/.codeium/windsurf/mcp_config.json. Same shape.

ChatGPT desktop / any other MCP-aware host

Use the same shape — point the host at node /ABS/PATH/.../mcp/dist/index.js, pass env vars through the host's MCP config interface.

Free-only mode (no keypair)

Omit MAGPIE_MCP_PAYER_KEYPAIR and the read-only free tools still work. Paid tools — and the envelope-signed exit tools (magpie_arm_exit, magpie_modify_exit, magpie_cancel_exit, which need the keypair to sign the envelope even though modify/cancel cost nothing) — return a clear error explaining that no payer is configured. Useful for read-only research agents or as a no-friction first install.

Environment variables

VariableDefaultPurpose
MAGPIE_X402_BASE_URLhttps://x402.magpie.capitalOverride for self-hosted or testnet deployments
SOLANA_RPC_URLhttps://api.mainnet-beta.solana.comRPC used to send x402 payment txs. Public RPC rate-limits aggressively — use Helius/Triton/QuickNode for any real volume.
MAGPIE_MCP_PAYER_KEYPAIR(unset)Path to a Solana keypair JSON in the standard solana-keygen format. Enables paid tools.

Cost ceiling

The keypair you configure is the only place SOL can leave. Per-call costs are exact (the server doesn't ever pay more than the 402 challenge demands), but if you're paranoid about runaway tool-calls during agent experimentation, fund the payer wallet with a small float — say 0.05 SOL — and let it run dry rather than top it up unattended.

Security model

  • The MCP server reads but never modifies your keypair file. The keypair is loaded into memory once at startup; the signature for each paid call happens locally; only the resulting tx signature ever leaves your machine (sent to magpie-x402 in the X-Payment header).
  • The Magpie x402 service has no way to sign anything on your behalf. Even with a complete compromise of x402.magpie.capital, the worst case is that you pay for tool calls you didn't get useful results from. Your keypair is not exposed.
  • For high-stakes write paths (build-borrow, build-deposit, etc.) the server returns an unsigned tx. Your agent receives it as plain text; you decide whether to sign + submit it. The MCP server itself never signs anything besides x402 payment transfers.

Troubleshooting

Tool doesn't appear in host UI — restart the host after editing config. Most hosts only re-read the MCP config on launch.

402 error on a paid tool — MAGPIE_MCP_PAYER_KEYPAIR is unset or the file doesn't exist. Run solana-keygen new -o ~/.config/solana/magpie-mcp.json and point the env var at the result, then solana transfer … a small SOL float in.

fetch failed on x402.magpie.capital — check the URL is reachable from your machine. If you're behind a corporate proxy, set HTTPS_PROXY in the same env block.

RPC rate-limit during a paid call — switch SOLANA_RPC_URL to a paid Helius/Triton/QuickNode URL. The default api.mainnet-beta.solana.com will throttle under any sustained use.

For maintainers — publishing to npm

The package is set up for npm publish with no additional configuration. From mcp/:

bash
# One-time per machine:npm login --scope=@magpieloans
# Each release:# 1. Bump version in package.json (semver)# 2. Publish — prepublishOnly rebuilds dist/ and chmod +x's the binarynpm publish

The package is scoped (@magpieloans/magpie-mcp) and publishConfig.access: "public" is set, so publish doesn't require any extra flags. The files field whitelists what ships — only dist/, README.md, LICENSE end up in the tarball (~9 KB).

Verify the contents before publish:

bash
npm pack --dry-run

License

MIT.

來源:mcp/README.md,提交 43a146c

工具

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

版本歷史

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

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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