MAIN MCP
MAIN MCP 服务器
Base 上 MAIN DEX 的 MCP (Model Context Protocol) 服务器。为 AI 智能体(Claude、Cursor 等)提供与协议交互的工具:代币兑换、流动性管理、进入/退出 ALM 策略等。
连接到 Claude
Claude Code:
claude mcp add main-mcp --transport http https://api.main.exchange/mcpMCP 协议
该服务器通过可流式传输的 HTTP 协议实现了 MCP spec 2025-03-26。
# Initialize
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0.0"}}}'
# List tools
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' \
| jq '.result.tools[] | {name, description}'
# Health
curl https://api.main.exchange/mcp/healthx402 支付
部分工具需要通过 x402 协议 进行 USDC 支付。当调用付费工具而未支付时,服务器会返回一个包含支付要求(金额、收款人、网络)的 JSON-RPC 错误。兼容 x402 的客户端会自动处理此流程。
付费工具:createPool, launchToken
工具
代币
getTokens — 获取协议中按交易量排序的所有代币。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getTokens","arguments":{}}}' \
| jq '.result.content[0].text | fromjson'approveTokens — 准备 ERC20 授权交易。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"approveTokens","arguments":{"tokenAddress":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","spenderAddress":"0x002E67c3F7BF96eB3aA4066073923e415581d385"}}}' \
| jq '.result.content[0].text | fromjson'launchToken (通过 x402 付费) — 在 MAIN 上发布新的 ERC-20 代币。返回 TokenFactory.createToken 的调用数据。Logo 和横幅必须提前上传到 IPFS(请参阅工具描述中的 IPFS 上传端点)。所有代币数据在创建后均不可更改。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"launchToken","arguments":{"name":"My Token","symbol":"MTK","totalSupply":"10000000","logo":"bafkreibgxsqxrkrha3oqoatypp4gpuemft47ablrgxkfucqn2rvhsdwaka","description":"A cool token","website":"https://example.com"}}}' \
| jq '.result.content[0].text | fromjson'交易
getPrice — 获取兑换报价:给定 tokenIn 数量可获得多少 tokenOut。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getPrice","arguments":{"amount":"1000000000000000000","tokenIn":"0x4200000000000000000000000000000000000006","tokenOut":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"}}}' \
| jq '.result.content[0].text | fromjson'quoteSwap — 获取完整的兑换报价,包含通过 SwapRouter 执行的调用数据。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"quoteSwap","arguments":{"amountIn":"1000000","tokenIn":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","tokenOut":"0x4200000000000000000000000000000000000006","recipient":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'资金池
getPools — 获取具有 TVL、交易量和费用的流动性池。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getPools","arguments":{}}}' \
| jq '.result.content[0].text | fromjson'getPoolAPR — 获取资金池 APR(所有资金池或特定资金池)。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getPoolAPR","arguments":{}}}' \
| jq '.result.content[0].text | fromjson'addLiquidityToPool — 准备向 Algebra 资金池添加流动性的交易。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"addLiquidityToPool","arguments":{"poolAddress":"0xPOOL","amount0":"1000000000000000000","amount1":"1000000","userAddress":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'removeLiquidityFromPool — 准备移除流动性的交易。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"removeLiquidityFromPool","arguments":{"tokenId":"123","percentage":100,"userAddress":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'createPool (通过 x402 付费) — 在 MAIN 上创建并初始化一个新的 CLMM 资金池。接受任意顺序的代币和人类可读的价格。该工具会在链上获取代币小数位数、对代币进行排序、计算 sqrtPriceX96,并检查资金池是否已存在。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"createPool","arguments":{"tokenA":"0xTOKEN_A","tokenB":"0xTOKEN_B","price":"0.1"}}}' \
| jq '.result.content[0].text | fromjson'头寸
getPositions — 获取地址的所有未平仓流动性头寸。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getPositions","arguments":{"userAddress":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'智能钱包
ALM 策略通过智能钱包执行——这是一种为每个用户部署的确定性代理合约。在进入任何策略之前,智能钱包必须已在链上存在。
deploySmartWallet — 为用户部署智能钱包。在使用任何策略工具之前必须先调用一次。交易必须直接从用户的 EOA 发送(工厂使用 msg.sender 作为部署盐值)。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"deploySmartWallet","arguments":{"userAddress":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'策略
getStrategies — 获取带有指标的可用 ALM 策略。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getStrategies","arguments":{}}}' \
| jq '.result.content[0].text | fromjson'getStrategyPositions — 获取用户在 ALM 策略中的头寸。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"getStrategyPositions","arguments":{"userAddress":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'enterToStrategy — 进入 ALM 策略。返回智能钱包的调用数据。需要已部署的智能钱包(请先使用 deploySmartWallet)。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"enterToStrategy","arguments":{"strategyId":"alm-v1","amount0":"500000","amount1":"0","userAddress":"0xYOUR_ADDRESS","duration":86400,"stopLoss":10,"takeProfit":25}}}' \
| jq '.result.content[0].text | fromjson'exitFromStrategy — 退出 ALM 策略。需要已部署的智能钱包。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"exitFromStrategy","arguments":{"strategyId":"alm-v1","positionId":"5","percentage":10000,"userAddress":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'increaseStrategy — 增加 ALM 策略中的头寸。需要已部署的智能钱包。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"increaseStrategy","arguments":{"strategyId":"alm-v1","positionId":"5","amount0":"500000","amount1":"0","userAddress":"0xYOUR_ADDRESS"}}}' \
| jq '.result.content[0].text | fromjson'广播
broadcastTx — 将已签名的交易广播到区块链。
curl -s -X POST https://api.main.exchange/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"broadcastTx","arguments":{"signedTxHex":"0xSIGNED_TX"}}}' \
| jq '.result.content[0].text | fromjson'This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/asdener123/MAIN-MCP-Server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server