Table of Contents
- AI Agents Need an Execution Layer
- MAIN MCP: One Server, Full DeFi Access
- Connect in One Line
- What Agents Can Do
- Workflow 1: Token Swapping
- Example: Swapping 5 USDC for WETH
- Workflow 2: Liquidity Management
- Example: Finding the Best Pool in Claude Code
- Workflow 3: Automated Strategies
- Example: Entering a Stable Strategy in Claude Code
- Workflow 4: Transaction Broadcast
- How It Works
- Get Started
Do not index
MAIN MCP is a single integration point for AI agents to execute DeFi actions on Base.
The same infrastructure powering MAIN DEX is now accessible through a standardized MCP server, enabling any AI agent to swap tokens, manage liquidity, and run automated strategies through natural language.
AI Agents Need an Execution Layer
The agent economy is emerging in real-time. AI agents can monitor markets, evaluate risk, and make decisions autonomously. But when it comes to executing DeFi actions onchain, they hit a wall.
The current landscape is fragmented. Agents need to construct raw transactions, manage approvals, handle smart wallet interactions, and coordinate across multiple contracts while maintaining deterministic execution.
This gap between agent intelligence and onchain execution is where MAIN comes in.
MAIN MCP: One Server, Full DeFi Access
MAIN now operates a hosted MCP (Model Context Protocol) server that wraps the entire MAIN DEX into structured tools that AI agents can call directly. This removes the need for agents to construct HTTP requests manually, interact with ABIs, or manage transaction encoding. Instead, every DeFi action is exposed as a callable function through a standardized protocol.
- Endpoint: https://api.main.exchange/mcp
- Protocol: MCP spec 2025-03-26 over Streamable HTTP
- Compatible with: Claude, Claude Code, Cursor, and any MCP-compatible client.
Connect in One Line
For Claude Code:
claude mcp add main-mcp --transport http https://api.main.exchange/mcpOnce connected, the agent can discover and call any MAIN tool natively within a conversation. No SDK installation, no API key management, no configuration files.
What Agents Can Do
MAIN MCP exposes the full DeFi stack as structured workflows. Each workflow maps to one or more MCP tools that agents can compose together.
Workflow 1: Token Swapping
Agents can get price quotes and execute swaps through MAIN’s SwapRouter. The
getPrice tool returns a quote for any token pair, and quoteSwap returns full calldata ready for execution. This enables agents to compare prices, find optimal routes, and execute trades in a single conversation.Supporting tools:
getTokens returns all protocol tokens sorted by volume, and approveTokens prepares ERC20 approvals for the SwapRouter contract.Example: Swapping 5 USDC for WETH
Here’s what Workflow 1 looks like in practice. A user connects MAIN MCP to Claude Code and asks a simple question in natural language. The agent discovers available tokens, fetches a live quote, and returns the result without the user touching an ABI, a block explorer, or a single line of code.
Prompt:
How much WETH would I get if I swap 5 USDC on MAIN?
What Claude does behind the scenes:
Step 1 — Calls getTokens
Discovers USDC (0x8335…89f…) and WETH (0x4200…06) with their decimals.
Step 2 — Calls getPrice with 5000000 (5 USDC in wei)
Returns amountOut: 2157432599220518 (≈ 0.00216 WETH)
Step 3 — Agent responds in plain English
Swapping 5 USDC would get you approximately 0.00216 WETH at the current rate.
To execute, the user says "go ahead and swap" and the agent calls
quoteSwap to get the full calldata, signs through the connected wallet, and broadcasts via broadcastTx. Three tool calls, one sentence from the user, fully onchain.The best prompts for Claude Code are simple and direct. Here are a few examples that work well:
Price check:
What’s the best rate for swapping 100 USDC to WETH on MAIN?
Execute a swap:
Swap 10 USDC for WETH on MAIN and broadcast the transaction
Discover available tokens:
What tokens can I trade on MAIN? Show me by volume
Workflow 2: Liquidity Management
Agents can provide and manage concentrated liquidity in MAIN’s Algebra-based pools. The
getPools tool returns all active pools with TVL, volume, and fee data. getPoolAPR returns current yield metrics. Agents can then use addLiquidityToPool and removeLiquidityFromPool to manage positions, while getPositions tracks all open NFT positions for a given address.This gives agents the complete toolkit for autonomous yield farming and position management.
Example: Finding the Best Pool in Claude Code
Prompt:
Show me all pools on MAIN with their APR and TVL. Which one has the best yield?
What Claude does:
Step 1 — Calls getPools
Returns 3 pools: WETH/USDC ($769 TVL, $24K volume), USDC/USDT ($900 TVL, $8.9K volume), USDC/ADAD ($10 TVL).
Step 2 — Calls getPoolAPR
Cross-references APRs. Highest yield: 37.5% APR. Matches and presents results in a ranked table.
Step 3 — Agent recommends and offers to execute
"The best yield is 37.5% APR. Want me to add liquidity to that pool?"
The user says "yes, add $50 in liquidity" and the agent calls
approveTokens for both tokens, then addLiquidityToPool with the calculated amounts. The agent handles decimals, tick ranges, and contract addresses automatically.More prompts that work well:
Add $100 of liquidity to the WETH/USDC pool on MAIN
Show my open liquidity positions and their current value
Remove 50% of my liquidity from position #42
Workflow 3: Automated Strategies
MAIN’s Automated Liquidity Management (ALM) strategies let agents deploy capital into actively managed positions with built-in risk controls. This is where MAIN MCP delivers capabilities beyond basic DEX tooling.
Agents can use
getStrategies to discover available strategies (volatile or stable), then enterToStrategy to deploy capital with configurable parameters: duration (1 day to 9 months), stop-loss (5–50%), and take-profit (5–50%). Ongoing management is handled through increaseStrategy and exitFromStrategy, while getStrategyPositions provides real-time position tracking.ALM strategies execute through a deterministic smart wallet deployed per user via
deploySmartWallet. This architecture ensures that agents can operate autonomously while maintaining isolated execution contexts for each user.Example: Entering a Stable Strategy in Claude Code
Prompt:
Enter the stable strategy on MAIN with $5, set a 10% stop-loss, 1 month duration
What Claude does:
Step 1 — Calls getStrategies
Discovers 2 strategies: ALM v1 (volatile, $0.51 TVL, 3 positions) and ALM Stable v1 (stable, $5.02 TVL, 2 positions). Selects alm-stable-v1.
Step 2 — Calls enterToStrategy
Splits $5 into $2.50 USDC + $2.50 USDT (2500000 wei each). Sets stopLoss: 10, duration: 2592000 (1 month). Returns smart wallet calldata.
Step 3 — Signs via wallet + calls broadcastTx
Agent signs the calldata through the connected wallet (OKX or any agentic wallet), broadcasts, and confirms the position is live.
One sentence from the user. The agent handled the full lifecycle from intent to onchain execution: strategy discovery, amount splitting, wei conversion, calldata generation, signing, and broadcasting.
More prompts that work well:
What strategies are available on MAIN? Compare volatile vs stable
Put $20 in the volatile strategy with 15% stop-loss and 30% take-profit
Show my strategy positions and exit the one that’s in profit
Add another $10 to my existing stable strategy position
Workflow 4: Transaction Broadcast
After an agent constructs and signs a transaction,
broadcastTx submits the signed hex to the Base network. This completes the execution loop: agents generate calldata through any of the above workflows, sign through their wallet provider (OKX or any agentic wallet), and broadcast through MAIN’s infrastructure.Full MCP tool reference: MAIN MCP README on GitHub
How It Works
MAIN MCP implements the Model Context Protocol specification (2025-03-26) over Streamable HTTP. The architecture is designed for reliability and simplicity:
- Agent-native interface. AI agents call structured tools through MCP. No HTTP request construction, no ABI encoding, no manual parameter formatting. The server handles all translation between natural language intent and onchain execution.
- Smart wallet execution. ALM strategies run through deterministic proxy contracts deployed per user. This isolates each agent’s execution context and enables complex DeFi operations (delegate calls, multi-step transactions) that simple EOA wallets can’t perform.
- Wallet-agnostic. MAIN MCP returns unsigned calldata and transaction parameters. Agents sign through their own wallet infrastructure: Coinbase Payments MCP, OKX Agentic Wallet, or any agentic EVM-compatible signer, then broadcast through MAIN’s endpoint.
- Base-native. Live on Base mainnet with production-grade architecture powering real transactions. Built on Algebra Integral for capital-efficient execution.

Get Started
A single MCP connection gives agents access to MAIN’s full capabilities: trading, liquidity, strategies, and transaction broadcasting. The protocol handles discovery, schema validation, and tool invocation, so agents can focus on decision-making.
Combined with agentic wallet infrastructure from Coinbase (Payments MCP, AgentKit) and OKX (Agentic Wallet), agents can now operate the complete lifecycle: discover opportunities, execute transactions, and manage positions autonomously.
MAIN MCP is live today. Connect your agent and start executing.
- MCP Endpoint: https://api.main.exchange/mcp
- Full Tool Reference: MAIN MCP README (GitHub Gist)
- Live Platform: app.main.exchange
- Contact: Telegram: @renedsaa


