by kukapay
An MCP server for AI agents to automate token swaps on Uniswap DEX across multiple blockchains.
Uniswap Trader MCP is an MCP (Multi-Chain Protocol) server designed to enable AI agents to automate token swaps on the Uniswap Decentralized Exchange (DEX) across various blockchain networks. It provides a programmatic interface for AI agents to interact with Uniswap V3, facilitating automated trading strategies and liquidity management.
To use Uniswap Trader MCP, you first need to install it. You can do this either via Smithery for automatic installation with Claude Desktop or through manual installation by cloning the repository and installing dependencies. Configuration involves setting up environment variables for your Infura key and wallet private key. Once set up, AI agents can interact with the server using defined tools like getPrice
to fetch real-time price quotes and executeSwap
to perform token swaps. The project supports multiple blockchains, and each chain needs to be configured with a valid RPC URL, WETH address, and SwapRouter address.
Q: What are the prerequisites for running Uniswap Trader MCP? A: You need Node.js (version 14.x or higher), npm, a funded wallet with a private key, and access to blockchain RPC endpoints for supported chains.
Q: Which blockchains are supported? A: Uniswap Trader MCP supports Ethereum, Optimism, Polygon, Arbitrum, Celo, BNB Chain, Avalanche, and Base.
Q: How do I get a price quote for a swap?
A: You can use the getPrice
tool, specifying the chainId
, tokenIn
, tokenOut
, and either amountIn
or amountOut
along with the tradeType
.
Q: How do I execute a swap?
A: You use the executeSwap
tool, providing similar parameters as getPrice
, along with optional slippageTolerance
and deadline
.
Q: Is there a license for this project? A: Yes, it is released under the MIT License.
An MCP server for AI agents to automate token swaps on Uniswap DEX across multiple blockchains.
To install Uniswap Trader MCP for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @kukapay/uniswap-trader-mcp --client claude
Clone the Repository:
git clone https://github.com/kukapay/uniswap-trader-mcp.git
cd uniswap-trader-mcp
Install Dependencies:
npm install
{
"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"
}
}
}
}
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 |
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"
}
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"
}
MIT License. See LICENSE for details.
Reviews feature coming soon
Stay tuned for community discussions and feedback