MCP ExplorerExplorer

Uniswap Mcp

@yurenjuon a year ago
1 MIT
FreeCommunity
AI Systems
Uniswap MCP implements the Model Context Protocol for research and testing.

Overview

What is Uniswap Mcp

Uniswap MCP (Model Context Protocol) is an experimental research project that implements the Model Context Protocol for Uniswap using Protocolink and Moralis libraries.

Use cases

Use cases for Uniswap MCP include testing token swaps, conducting research on DeFi protocols, and developing applications that require wallet interactions on the Optimism network.

How to use

To use Uniswap MCP, install the required dependencies with ‘npm install’, generate a new wallet with ‘npm run generate-wallet’, configure your environment variables, and fund your wallet for testing on the Optimism network.

Key features

Key features of Uniswap MCP include wallet generation, integration with Moralis API for blockchain interactions, and the ability to perform swaps on the Optimism network.

Where to use

Uniswap MCP can be used in decentralized finance (DeFi) applications, blockchain research, and testing environments for wallet and transaction management.

Content

Uniswap MCP (Model Context Protocol)

This package implements the Model Context Protocol for Uniswap using Protocolink and Moralis libraries.

⚠️ IMPORTANT NOTICE
This is an experimental research project:

  • Do not store large amounts of funds in the generated wallet
  • Use this for research and testing purposes only

Prerequisites

  • Node.js and npm installed
  • Moralis API key (Sign up at Moralis)

Installation

  1. Install all dependencies:
npm install
  1. Generate a new wallet:
npm run generate-wallet
  1. Configure environment variables:

    • Refer to .env.example for the required environment variables format
    • Add your Moralis API key to the generated .env file
  2. Fund your wallet for testing (on Optimism network):

    • Transfer 0.01 ETH to your generated wallet address on Optimism (for gas fees)
    • Transfer 20 USDC to your generated wallet address on Optimism (for swap testing)
    • You can check your wallet balance using npm run get-wallet-info

Environment Variables

Please refer to .env.example for the required environment variables:

  • MORALIS_API_KEY: Your Moralis API key
  • WALLET_PRIVATE_KEY: Your wallet’s private key (automatically generated by npm run generate-wallet)

Claude Desktop Integration

To use this MCP server with Claude Desktop:

  1. Build the project:
npm run build

This will create the server bundle at build/index.js

  1. Open Claude Desktop settings:

    • On macOS: Click on the Claude menu and select “Settings…”
    • On Windows: Click on the Claude icon in the system tray and select “Settings…”
  2. In the Settings window:

    • Click on “Developer” in the left sidebar
    • Click on “Edit Config” to open the configuration file
  3. Edit the configuration file (claude_desktop_config.json):

    • Location on macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Location on Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the following configuration:

{
  "mcpServers": {
    "uniswap": {
      "command": "node",
      "args": [
        "path/to/your/build/index.js"
      ]
    }
  }
}

Replace path/to/your with the actual path to your project’s build directory.

  1. Restart Claude Desktop for the changes to take effect.

  2. Verify the installation:

    • You should see a hammer icon in the Claude interface
    • Type “Check my balance” in Claude Desktop
    • If the MCP server is properly connected, Claude will display your wallet balance using the get-wallet-info tool

balance screenshot

Testing Scripts

The following scripts are available for testing the environment:

Check Wallet Information

npm run get-wallet-info

Displays your wallet address and all token balances in your wallet.

Get Token Information

npm run token-info <token-symbol>

Example: npm run token-info USDC

Retrieves detailed information about a specific token, including:

  • Token name
  • Contract address
  • Decimals
  • Chain ID
  • Logo URI (if available)

Get Quote Information

npm run quote-info <token-symbol> <amount-in> [slippage]

Example: npm run quote-info OP 10 0.5

Fetches both buy and sell quotes for a token:

  • Buy quote: How much of the target token you’ll receive for your USDC
  • Sell quote: How much USDC you’ll receive for selling the target token
  • Default slippage is 0.5% if not specified

Execute Token Swap

npm run swap-test <fromTokenSymbol> <toTokenSymbol> <amount> <slippage> [--round-trip|-r]

Example:

  • Simple swap: npm run swap-test USDC OP 10 0.5
  • Round-trip swap: npm run swap-test USDC OP 10 0.5 --round-trip

Executes a token swap with the following features:

  • Swap between any supported token pairs
  • Optional round-trip mode that swaps back to the original token
  • Displays detailed transaction information including exchange rates and fees
  • Shows profit/loss calculation for round-trip swaps

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers