
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.
概览
一个本地 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 的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 Magpie Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
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 accountmagpie_protocol_pulse— 24h aggregates (active loans, volume, liquidations)magpie_recent_activity— anonymized borrow/repay/liquidate streammagpie_loan— single loan by IDmagpie_wallet_loans— all loans for a walletmagpie_tiers— protocol tier constantsmagpie_simulate_borrow— quote a loan without submittingmagpie_collateral_eligible— full collateral catalogmagpie_liquidatable— loans currently liquidatablemagpie_credit_leaderboard— top wallets by credit scoremagpie_lp_state— depositor position + pool contextmagpie_loan_by_pda— single loan by on-chain loan PDAmagpie_pools— Magpie lending pools (program-version lanes + context)magpie_list_exits— armed in-vault exit orders for a walletmagpie_modify_exit— change an armed exit's trigger / paramsmagpie_cancel_exit— cancel an armed exit (loan stays Active)
Paid (require a configured Solana keypair):
magpie_credit_score— 0.001 SOLmagpie_token_risk— 0.001 SOL (per-token risk profile)magpie_build_borrow— 0.005 SOL (passhas_exit_arming: trueto route into the V4 in-vault-exit lane)magpie_build_repay— 0.002 SOLmagpie_build_deposit— 0.002 SOLmagpie_build_withdraw— 0.002 SOLmagpie_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. Setdirection(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"), ortrailing_bps(stop-loss only). Optionalslippage_bps,dest(sol|usdc), andslicefor 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:
Then in your host config:
Path B — from source
If the npm package isn't published yet, or you want to hack on the server:
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):
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
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-Paymentheader). - 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/:
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:
License
MIT.
来源:mcp/README.md,提交 43a146c
工具
0版本历史
1- v0.1.1最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分