The Uniswap Trader MCP server enables AI agents to automate token swaps on Uniswap DEX across multiple blockchains, providing features like real-time price quotes, swap execution, trading suggestions, and support for various networks including Ethereum, Optimism, Polygon, and others.
Before installing the Uniswap Trader MCP server, ensure you have:
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
Create a configuration file with your environment variables:
{
"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:
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 |
Use the getPrice
tool to fetch real-time price quotes for token swaps.
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.
Example 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"
}
Use the executeSwap
tool to perform token swaps 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.
Example 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"
}
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "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"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"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"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"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"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect