Automate Uniswap Token Swaps Across Blockchains
An MCP server letting AI agents price and execute Uniswap V3 swaps across 8 blockchains.
Why it matters
Empower AI agents to execute automated token swaps on Uniswap V3 across multiple blockchains. This MCP server provides tools for fetching real-time price quotes and executing trades with configurable parameters.
Outcomes
What it gets done
Fetch real-time price quotes for token swaps with multi-hop route optimization.
Execute token swaps on Uniswap V3 with configurable slippage tolerance and deadlines.
Support for multiple blockchains including Ethereum, Optimism, Polygon, and Arbitrum.
Generate trade recommendations based on liquidity, fees, and optimal paths.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-uniswap-trader-mcp | bash Capabilities
Tools your agent gets
Fetches real-time price quotes for swaps on Uniswap with multi-hop route optimization
Executes token swaps on Uniswap V3 with configurable slippage tolerance and deadlines
Overview
uniswap-trader-mcp server
An MCP server letting AI agents price and execute Uniswap V3 token swaps across 8 blockchains with slippage control. Use it when an agent needs to price or execute a real on-chain Uniswap swap on a supported blockchain.
What it does
An MCP server that lets AI agents automate token swaps on Uniswap DEX across eight blockchains - Ethereum, Optimism, Polygon, Arbitrum, Celo, BNB Chain, Avalanche, and Base - getting real-time price quotes with multi-hop route optimization, executing swaps on Uniswap V3 with configurable slippage and deadlines, and generating trading suggestions based on liquidity and fees.
When to use - and when NOT to
Use this when an agent needs to price or execute a real Uniswap V3 swap on a supported chain - for example "Get me a price quote for swapping 1 ETH to DAI on Ethereum" or "Swap 1 ETH for DAI on Ethereum with a 0.5% slippage tolerance and a 20-minute deadline." It executes real on-chain transactions using a funded wallet's private key, so it should not be used without carefully configuring slippage tolerance and deadline, and it requires per-chain RPC access (e.g. Infura) plus a valid SwapRouter/WETH configuration in chainConfigs.js for each chain used.
Capabilities
getPrice: fetches a price quote for a swap -chainId,tokenIn,tokenOut,amountInoramountOut,tradeType(exactIn/exactOut) - returning price, minimum received, route, and estimated gas.executeSwap: executes the swap on-chain with the same parameters plusslippageTolerance(default 0.5%) anddeadline(default 20 minutes), returning the transaction hash, amounts, route, and gas used.- Swap suggestions generated from liquidity, fees, and optimal routing paths.
- Multi-chain support: Ethereum, Optimism, Polygon, Arbitrum, Celo, BNB Chain, Avalanche, and Base, each requiring its own RPC URL, WETH address, and SwapRouter address in
chainConfigs.js.
How to install
Requires Node.js 14+, npm, a funded wallet's private key, and RPC endpoint access (e.g. Infura) for each chain used. Via Smithery:
npx -y @smithery/cli install @kukapay/uniswap-trader-mcp --client claude
Or clone the repo and run npm install. Configure:
{
"mcpServers": {
"Uniswap-Trader-MCP": {
"command": "node",
"args": ["path/to/uniswap-trader-mcp/server/index.js"],
"env": {
"INFURA_KEY": "your infura key",
"WALLET_PRIVATE_KEY": "your private key"
}
}
}
}
Who it's for
Crypto traders and agent builders who want an AI agent to price and execute Uniswap swaps directly across multiple chains, without switching to the Uniswap web app for each trade. A getPrice response, for instance, returns the exact input/output amounts, minimum received, the multi-hop route with per-pool fees, and estimated gas, giving the agent (or the trader reviewing its output) enough detail to decide whether to proceed before ever calling executeSwap for real. The project is distributed under the MIT License.
Source README
Uniswap Trader MCP
An MCP server for AI agents to automate token swaps on Uniswap DEX across multiple blockchains.
Features
- Price Quotes: Get real-time price quotes for token swaps with multi-hop route optimization.
- Swap Execution: Execute swaps on Uniswap V3 with configurable slippage tolerance and deadlines.
- Swap Suggestions: Generate trading suggestions based on liquidity, fees, and optimal paths.
- Multi-Chain Support: Compatible with Ethereum, Optimism, Polygon, Arbitrum, Celo, BNB Chain, Avalanche, and Base.
Prerequisites
- Node.js: Version 14.x or higher.
- npm: For package management.
- Wallet: A funded wallet with a private key for executing swaps.
- RPC Endpoints: Access to blockchain RPC URLs (e.g., Infura, Alchemy) for supported chains.
Installation
Installing via Smithery
To install Uniswap Trader MCP for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @kukapay/uniswap-trader-mcp --client claude
Manual Installation
Clone the Repository:
git clone https://github.com/kukapay/uniswap-trader-mcp.git cd uniswap-trader-mcpInstall Dependencies:
npm install
Configuration
{
"mcpServers": {
"Uniswap-Trader-MCP": {
"command": "node",
"args": ["path/to/uniswap-trader-mcp/server/index.js"],
"env": {
"INFURA_KEY": "your infura key",
"WALLET_PRIVATE_KEY": "your private key"
}
}
}
}
Usage
Supported Chains
The following blockchains are supported. Ensure each chain is configured in chainConfigs.js with a valid RPC URL, WETH address, and SwapRouter address.
| Chain ID | Name | Notes |
|---|---|---|
| 1 | Ethereum | Mainnet, widely used for Uniswap trades |
| 10 | Optimism | Layer 2, requires Optimism RPC |
| 137 | Polygon | Fast and low-cost, uses MATIC as native |
| 42161 | Arbitrum | Layer 2, Arbitrum One network |
| 42220 | Celo | Mobile-first blockchain, uses CELO |
| 56 | BNB Chain | Binance Smart Chain, uses BNB |
| 43114 | Avalanche | High-throughput, uses AVAX |
| 8453 | Base | Coinbase’s Layer 2, built on Optimism |
Tools and Prompts
1. getPrice
Fetches a price quote for a Uniswap swap.
Schema:
chainId: Number (default: 1)tokenIn: String (e.g.,"NATIVE"or token address)tokenOut: String (e.g.,"NATIVE"or token address)amountIn: String (optional, required for"exactIn")amountOut: String (optional, required for"exactOut")tradeType:"exactIn"or"exactOut"(default:"exactIn")
Example prompt:
Get me a price quote for swapping 1 ETH to DAI on Ethereum.
Output:
{
"chainId": 1,
"tradeType": "exactIn",
"price": "3000.50",
"inputAmount": "1.000000",
"outputAmount": "3000.50",
"minimumReceived": "2985.50",
"maximumInput": "1.005000",
"route": [
{
"tokenIn": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"tokenOut": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"fee": 3000
}
],
"estimatedGas": "150000"
}
2. executeSwap
Executes a swap on Uniswap.
Schema:
chainId: Number (default: 1)tokenIn: StringtokenOut: StringamountIn: String (optional, required for"exactIn")amountOut: String (optional, required for"exactOut")tradeType:"exactIn"or"exactOut"(default:"exactIn")slippageTolerance: Number (default: 0.5, in percentage)deadline: Number (default: 20, in minutes)
Example prompt:
Swap 1 ETH for DAI on Ethereum with a 0.5% slippage tolerance and a 20-minute deadline.
Output:
{
"chainId": 1,
"txHash": "0x1234...abcd",
"tradeType": "exactIn",
"amountIn": "1.000000",
"outputAmount": "2990.75",
"minimumReceived": "2985.50",
"maximumInput": "1.005000",
"fromToken": "NATIVE",
"toToken": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"route": [
{
"tokenIn": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"tokenOut": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
"fee": 3000
}
],
"gasUsed": "145000"
}
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.