SwapAPI MCP server
✓ VerifiedEnables AI agents to retrieve executable token swap calldata for any EVM-compatible blockchain.
Also known as swap-api/swap-api, @swapapi/mcp
- Stars
- 22
- Tools
- 1
- Downloads, 30 days
- —
- Latest version
- 0.1.0
- Last commit
- Apr 3, 2026
- License
- MIT
What is SwapAPI MCP?
SwapAPI enables AI agents to retrieve executable token swap calldata for any EVM-compatible blockchain. It exposes 1 tool, such as sender.
Summary generated from the project's README
About SwapAPI MCP server
Retrieving executable transaction data for token swaps across various EVM-compatible blockchains is what this server enables for AI agents. Developers can integrate this tool into clients like Claude Desktop or Cursor to allow an agent to generate the specific calldata required to execute trades. By providing a chain ID, input and output token addresses, and the amount, the agent receives the router contract address, ABI-encoded data, and estimated gas limits.
Users set up the server locally using npm or npx to connect it to their preferred MCP-compatible client. The swap_tokens tool handles different network environments, such as Ethereum, Base, or Arbitrum, by utilizing the appropriate chain ID. It also supports setting a maxSlippage parameter to control price tolerance during the swap process. This setup allows an AI to act as a bridge between natural language requests and the technical requirements of decentralized finance protocols.
What you can do with it
- 1Generate swap calldata for BaseAsk the AI to prepare a transaction to swap 0.001 ETH for USDC on the Base network.
- 2Execute Arbitrum token tradesRequest the transaction data needed to swap USDC for ETH on Arbitrum with a specific slippage tolerance.
Written from the project's README. Every use case is checked against a quote from it.
How to install SwapAPI MCP
Formats verified 10 Nov 2026Add to CursorAdd to GooseInstall SwapAPI MCP in Claude Code
$ claude mcp add mcp -- npx -y @swapapi/mcpInstall SwapAPI MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@swapapi/mcp"
]
}
}
}Install SwapAPI MCP in VS Code
.vscode/mcp.json
{
"servers": {
"mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@swapapi/mcp"
]
}
}
}Install SwapAPI MCP in VS Code CLI
$ code --add-mcp '{"name":"mcp","type":"stdio","command":"npx","args":["-y","@swapapi/mcp"]}'Install SwapAPI MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@swapapi/mcp"
]
}
}
}Install SwapAPI MCP in Codex
$ codex mcp add mcp -- npx -y @swapapi/mcpInstall SwapAPI MCP in Codex config.toml
~/.codex/config.toml
[mcp_servers.mcp] command = "npx" args = ["-y", "@swapapi/mcp"]
Install SwapAPI MCP in Gemini CLI
$ gemini mcp add -s user mcp npx -- -y @swapapi/mcpInstall SwapAPI MCP in Gemini settings.json
~/.gemini/settings.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@swapapi/mcp"
]
}
}
}SwapAPI MCP tools 1
Detected from the READMEsender
| sender | — |
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the code and give the server the narrowest access it needs. How checks work
- Source repository linked and reachableswap-api/swap-api is public and reachablegithub.com/swap-api/swap-api ↗Pass
- Package names this repository as its source@swapapi/mcp names swap-api/swap-api as sourcenpmjs.com/package/@swapapi/mcp ↗Pass
- Build provenance (Sigstore attestation)No build attestation published for this releaseNot checked
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-04-03github.com/swap-api/swap-api ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNo popular package one edit away from @swapapi/mcpPass
- No critical advisory in the package or its dependencies99 resolved dependencies checked; no critical advisoryosv.dev ↗Pass
- No hidden instructions to the model1 tool description and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNo tool named like delete, drop or execPass
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubSwapAPI MCP Server
MCP (Model Context Protocol) server for SwapAPI. Enables AI agents to get executable token swap calldata for any EVM chain.
Installation
npm install -g @swapapi/mcp
Or use directly with npx:
npx @swapapi/mcp
Client Configuration
Claude Desktop
Add to your Claude Desktop config:
{
"mcpServers": {
"swapapi": {
"command": "npx",
"args": ["@swapapi/mcp"]
}
}
}
Or with a local install:
{
"mcpServers": {
"swapapi": {
"command": "npx",
"args": ["tsx", "/path/to/swap-api/mcp/mcp-server.ts"]
}
}
}
Cursor
Add to your Cursor settings (Settings → MCP):
{
"mcpServers": {
"swapapi": {
"command": "npx",
"args": ["@swapapi/mcp"]
}
}
}
Other Clients
Any MCP-compatible client can use the same configuration format. Check your client's documentation for where to add MCP server settings.
Available Tools
swap_tokens
Get executable transaction data to swap tokens on EVM chains.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
chainId |
number |
Yes | Chain ID (1=Ethereum, 8453=Base, 42161=Arbitrum, etc.) |
tokenIn |
string |
Yes | Input token address. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native token (ETH, MATIC, etc.) |
tokenOut |
string |
Yes | Output token address |
amountIn |
string |
Yes | Amount in smallest unit (wei for 18-decimal tokens, micro-units for 6-decimal tokens) |
sender |
string |
Yes | Wallet address that will sign and send the transaction |
maxSlippage |
number |
No | Max slippage tolerance 0-1 (default: 0.005 = 0.5%) |
Returns:
{
"to": "0x...", // Router contract address to call
"data": "0x...", // ABI-encoded swap calldata
"value": "1000000000000000000", // Native token value (if swapping from native)
"gas": "150000", // Estimated gas limit
"guaranteedOut": "..." // Minimum output amount after slippage
}
Examples
Swap 0.001 ETH to USDC on Base
{
"chainId": 8453,
"tokenIn": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"tokenOut": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amountIn": "1000000000000000",
"sender": "0xYourAddress"
}
Swap USDC to ETH on Arbitrum with 1% slippage
{
"chainId": 42161,
"tokenIn": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"tokenOut": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"amountIn": "10000000",
"sender": "0xYourAddress",
"maxSlippage": 0.01
}
Pre-flight Checklist
Before submitting any swap transaction:
- ERC-20 Approval: If
tokenInis not native token, ensure sender has approved the router for at leastamountIn - Balance Check: Verify sender has sufficient balance for
amountIn(plusvalueif native token) - Gas Estimation: Call
eth_estimateGason the transaction and add 20% buffer - Simulation: Run
eth_callto verify the transaction won't revert - Timing: Submit within 30 seconds of fetching the quote (calldata has expiry)
See the main README.md for full API documentation.
Development
cd mcp
npm install
npm start
Testing
Run the test suite:
npm test
Or use the MCP Inspector:
npx @modelcontextprotocol/inspector tsx mcp-server.ts
License
MIT
SwapAPI MCP questions
How do I add SwapAPI MCP to Claude Code?
Run claude mcp add mcp -- npx -y @swapapi/mcp in your terminal. Add --scope user to make it available in every project.
How do I add SwapAPI MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
What tools does SwapAPI MCP provide?
It exposes 1 tool, including sender.
How do I swap using a native token like ETH?
To use a native token as the input, use the address 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for the tokenIn parameter.
What should I check before submitting a swap transaction?
You should ensure ERC-20 approval is granted, verify the sender has sufficient balance, estimate gas with a buffer, simulate the transaction, and submit within 30 seconds.