UN

Uniswap Trader MCP Server for Cross-Chain Token Swaps

Automate cross-chain Uniswap token swaps with an MCP server for AI agents, executing secure multi-blockchain trades and streamlining liquidity routing.

Quick Install
npx -y @kukapay/uniswap-trader-mcp

Overview

The Uniswap Trader MCP Server provides a Model Context Protocol (MCP) endpoint that lets AI agents and automation systems programmatically orchestrate Uniswap-style token swaps across multiple EVM-compatible chains. It exposes standardized agent-facing actions — quote, simulate, and execute swaps — while managing chain RPCs, router addresses, gas estimation and on-chain signing (or relay to a key-management service). The server centralizes cross‑chain routing logic so agents can focus on high-level trading decisions instead of low-level blockchain plumbing.

This server is useful when you need repeatable, auditable automation for cross-chain trades, arbitrage, liquidity routing, or wallet batching. By offering an MCP-compatible interface, it integrates with agent frameworks that use the MCP to request context-aware tools, enabling LLM-based or programmatic agents to request precise quotes and initiate secure multi-blockchain transactions with clear pre- and post-execution feedback.

Features

  • MCP-compatible API for AI agents to request swap-related tools and operations
  • Cross-chain support for multiple EVM chains (configurable RPC endpoints)
  • Quoting and route selection across Uniswap-style routers (V2/V3-compatible)
  • Simulation / dry-run mode to validate gas, slippage, and revert reasons
  • Transaction execution with optional local signer or external KMS integration
  • Configurable slippage, gas strategies, and deadline management
  • Audit logs and structured responses for agent consumption
  • Dockerized deployment and environment-driven configuration

Installation / Configuration

Clone the repository and run using Node or Docker. The examples below assume a typical Node/TypeScript implementation.

Install and run locally:

git clone https://github.com/kukapay/uniswap-trader-mcp.git
cd uniswap-trader-mcp
# install deps (npm or yarn/pnpm)
npm install
npm run build
npm run start

Run with Docker:

# build
docker build -t uniswap-trader-mcp .

# run (example)
docker run -p 8080:8080 \
  -e MCP_PORT=8080 \
  -e RPC_URLS='{"1":"https://mainnet.infura.io/v3/..","137":"https://polygon-rpc.com"}' \
  -e UNISWAP_ROUTER_ADDRESSES='{"1":"0x...","137":"0x..."}' \
  uniswap-trader-mcp

Example .env configuration:

MCP_PORT=8080
LOG_LEVEL=info
RPC_URLS={"1":"https://mainnet.infura.io/v3/YOUR_KEY","137":"https://polygon-rpc.com"}
UNISWAP_ROUTER_ADDRESSES={"1":"0xE592427A0AEce92De3Edee1F18E0157C05861564","137":"0x..."}
SIGNER_TYPE=local        # local | kms | relay
PRIVATE_KEYS='["0x..."]' # only for local development
SLIPPAGE_BPS=50
DEADLINE_SECONDS=300

Security notes:

  • Never commit private keys. Use an external KMS in production.
  • Run in a private network or behind an authenticated gateway when exposing signing capabilities.
  • Limit agent scopes and add rate limits to prevent accidental mass execution.

Available Resources

Common API resources exposed by the MCP server (examples — actual endpoints may vary):

EndpointMethodDescription
/mcp/describeGETMCP capability descriptor for agents
/quotePOSTGet a quote for a swap (returns routes, expected amounts, gas estimate)
/simulatePOSTSimulate a swap transaction (revert reasons, gas usage)
/swapPOSTExecute or submit a signed swap transaction
/status/:txGETTransaction execution status and receipt

Example quote request (JSON):

{
  "fromChain": "1",
  "toChain": "137",
  "fromToken": "0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
  "toToken": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
  "amountIn": "1000000",
  "slippageBps": 50
}

Use Cases

  • Cross-chain swap automation for a wallet or bot:
    • An LLM agent identifies a favorable rate on Polygon versus Ethereum. It calls /quote to compare routes, simulates the transaction, and then invokes /swap to execute, letting the MCP server handle RPC selection, gas estimation and signing.
  • Arbitrage or market-making:
    • A market-making system queries quotes across multiple routers and chains, simulates candidate transactions to ensure profitability after gas and slippage, and submits only validated swaps.
  • Batch user migrations / payroll:
    • Finance teams can route multi-user token conversions across chains with consistent slippage and deadlines, batching and tracking receipts via /status.
  • Research and backtesting:
    • Use the simulate endpoint to validate strategies without spending funds, replaying historical state or testnet blocks.

Getting Help and Next Steps

  • Repository: https://github.com/kukapay/uniswap-trader-mcp
  • Suggested next steps: configure a KMS signer, add chain-specific router addresses, and integrate the MCP descriptor into your agent orchestration so AI tools can discover and call swap operations programmatically.

This MCP server is intended as a developer-facing building block for integrating cross-chain Uniswap-style swaps into agent workflows and automation systems. Adjust configuration and signing strategy according to your production security and compliance requirements.

Tags:finance