mcp · swap-api — Claude Code MCP server: token swap calldata for EVM
SwapAPI's MCP server hands your agent executable calldata for token swaps on EVM chains. Useful when the swap has to be assembled inside the chat.
claude mcp add mcp -- npx -y @swapapi/mcpWhat mcp does
There is one tool, swap_tokens. It takes a chainId, the tokenIn and tokenOut addresses, amountIn in the smallest units, the sender wallet, and optionally maxSlippage from 0 to 1 (0.005 by default). What comes back: the router address in to, ABI-encoded data, a value field for native coins, an estimated gas limit and the guaranteed output after slippage.
No transaction leaves the server. It only builds the payload; your wallet signs and broadcasts. The README's checklist follows from that: approve an ERC-20 first, confirm the balance, run eth_estimateGas with headroom, dry-run with eth_call. Timing matters too. Calldata expires, so act on a quote quickly rather than parking it in a queue.
For a native coin on either side, pass 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE as the token address. The server never needs a private key, which keeps signing keys out of your MCP config. Default slippage of 0.5% is a tight fit for volatile pairs; set it yourself when the trade calls for it.
What it helps with
- build swap calldata for a given EVM chain
- turn ETH into USDC from inside an agent chat
- work out the minimum output after slippage
- get router address and gas estimate for a Base or Arbitrum trade
Example prompts for the agent
- Build the calldata to swap 0.001 ETH for USDC on Base, my wallet is 0xYourAddress
- Prepare a USDC to ETH swap on Arbitrum with 1% slippage
- Call
swap_tokensfor chainId 1 with 1000000000000000 wei
How to install mcp
Platform CLI
claude mcp add mcp -- npx -y @swapapi/mcpPlatform CLI
codex mcp add mcp -- npx -y @swapapi/mcpConfig file
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@swapapi/mcp"
]
}
}
}Config file
{
"servers": {
"mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@swapapi/mcp"
]
}
}
}Platform CLI
gemini mcp add mcp npx -y @swapapi/mcpStep by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about mcp
How do I install mcp in Claude Code?
Run claude mcp add mcp -- npx -y @swapapi/mcp. The server is registered and swap_tokens becomes available in the session.
What does mcp do?
It returns swap transaction data: router address, calldata, value for native coins, gas estimate and the post-slippage minimum. Signing and sending stay with your wallet.
What should I check before sending a swap?
Approve the router for at least amountIn when swapping an ERC-20, verify the balance and dry-run with eth_call for reverts. Use the quote promptly, since calldata expires.
Similar MCP servers
All MCP servers for Agent setup: memory, context, orchestration →mcp by other authors comes first.