DeFi Trading Agent MCP server

Transforms conversational interfaces into autonomous DeFi trading agents with real-time market analysis, portfolio management, and seamless trade execution across 17+ blockchains including Ethereum, Base, and Arbitrum through 0x API swap aggregation and gasless trading support.
Back to servers
Setup instructions
Provider
Ed
Release date
Aug 02, 2025
Language
TypeScript
Stats
11 stars

The DeFi Trading Agent MCP Server transforms your AI assistant into an autonomous crypto trading agent with real-time market analysis, portfolio management, and trade execution capabilities across multiple blockchains.

Installation

Quick Start

Install the package globally:

npm install -g defi-trading-mcp

Create a new wallet (recommended):

npx defi-trading-mcp --create-wallet

This generates a new wallet with private key and address for secure trading.

Configuration Requirements

Before using the trading agent, you'll need to configure these essential keys:

  • USER_PRIVATE_KEY: Your private key (stays local, never transmitted)
  • USER_ADDRESS: Your Ethereum wallet address
  • COINGECKO_API_KEY: For market data access
  • ALCHEMY_API_KEY: (Optional) For premium RPC connections

MCP Client Setup

Kiro IDE Setup

  1. Install the MCP:
npm install -g defi-trading-mcp
  1. Add to ~/.kiro/settings/mcp.json:
{
  "mcpServers": {
    "defi-trading": {
      "command": "npx",
      "args": ["defi-trading-mcp"],
      "env": {
        "USER_PRIVATE_KEY": "your_private_key_here",
        "USER_ADDRESS": "0xYourWalletAddress",
        "COINGECKO_API_KEY": "CG-your_coingecko_api_key",
        "ALCHEMY_API_KEY": "your_alchemy_api_key"
      }
    }
  }
}

Claude Code Setup

  1. Install the MCP:
npm install -g defi-trading-mcp
  1. Add to Claude Code (macOS/Linux/WSL):
claude mcp add defi-trading \
  -e USER_PRIVATE_KEY=your_private_key_here \
  -e USER_ADDRESS=0xYourWalletAddress \
  -e COINGECKO_API_KEY=CG-your_coingecko_api_key \
  -e ALCHEMY_API_KEY=your_alchemy_api_key \
  -- npx defi-trading-mcp

For Windows (native):

claude mcp add defi-trading \
  -e USER_PRIVATE_KEY=your_private_key_here \
  -e USER_ADDRESS=0xYourWalletAddress \
  -e COINGECKO_API_KEY=CG-your_coingecko_api_key \
  -e ALCHEMY_API_KEY=your_alchemy_api_key \
  -- cmd /c npx defi-trading-mcp
  1. Verify the MCP is added:
claude mcp list

Claude Desktop Setup

  1. Install the MCP:
npm install -g defi-trading-mcp
  1. Open Claude Desktop, click the top left menu, select Developer, then Open App Config File.

  2. Add the following to the config file:

{
  "mcpServers": {
    "defi-trading": {
      "command": "npx",
      "args": ["defi-trading-mcp"],
      "env": {
        "USER_PRIVATE_KEY": "your_private_key_here",
        "USER_ADDRESS": "0xYourWalletAddress",
        "COINGECKO_API_KEY": "CG-your_coingecko_api_key",
        "ALCHEMY_API_KEY": "your_alchemy_api_key"
      }
    }
  }
}

Cursor Setup

  1. Install the package:
npm install -g defi-trading-mcp
  1. Add to Cursor configuration:
    • Open Cursor
    • Go to Settings → Extensions → MCP Servers
    • Add a new server with this configuration:
{
  "defi-trading": {
    "command": "npx",
    "args": ["defi-trading-mcp"],
    "env": {
      "USER_PRIVATE_KEY": "your_private_key_here",
      "USER_ADDRESS": "0xYourWalletAddress",
      "COINGECKO_API_KEY": "CG-your_coingecko_api_key",
      "ALCHEMY_API_KEY": "your_alchemy_api_key"
    }
  }
}

Other MCP Clients

For other MCP clients, find the equivalent configuration file and use this pattern:

{
  "mcpServers": {
    "defi-trading": {
      "command": "npx",
      "args": ["defi-trading-mcp"],
      "env": {
        "USER_PRIVATE_KEY": "your_private_key_here",
        "USER_ADDRESS": "0xYourWalletAddress",
        "COINGECKO_API_KEY": "CG-your_coingecko_api_key",
        "ALCHEMY_API_KEY": "your_alchemy_api_key"
      }
    }
  }
}

Usage Examples

Simple Quote

Get me a quote for 0.1 eth to usdc on Base chain.

Quote and Swap

Get me a quote for 0.1 eth on ethereum chain and execute the swap.

Memecoin Opportunity Scanner

Scan for newly launched memecoins on Base with >$100K liquidity, pick one or two tokens and analyze the best entry opportunities

Risk Management

Monitor my portfolio and alert me if any position drops more than 15%

Available Trading Tools

Portfolio Management

  • get_portfolio_tokens - Multi-chain portfolio analysis with prices and metadata
  • get_portfolio_balances - Fast balance checking across all chains
  • get_portfolio_transactions - Complete transaction history analysis

Market Intelligence & Analysis

  • get_trending_pools - Identify hot trading opportunities with volume metrics
  • get_new_pools - Discover newly launched tokens and liquidity pools
  • get_pool_ohlcv - Technical analysis with OHLCV candlestick data
  • get_pool_trades - Analyze recent trading activity
  • get_token_price - Real-time pricing with 24h change indicators
  • get_token_data - Deep token research with metadata and social links
  • get_token_info - Comprehensive token analysis including descriptions
  • search_pools - Find specific pools by token symbol or contract address

Smart Trading

  • get_swap_price - Get best prices across all DEXes
  • get_swap_quote - Get executable quotes with transaction data
  • execute_swap - Execute trades with optimal routing
  • get_supported_chains - List all 17+ supported blockchains

Gasless Trading

  • get_gasless_price - Get prices for gas-free trades
  • get_gasless_quote - Get gasless swap quotes
  • submit_gasless_swap - Execute trades without holding ETH
  • get_gasless_status - Monitor gasless transaction status

Supported Networks

The trading agent supports 17+ blockchain networks including:

  • Ethereum
  • Base
  • Polygon
  • Arbitrum
  • Optimism
  • BSC
  • Avalanche
  • Blast
  • Linea
  • Scroll
  • Mantle
  • Mode
  • Worldchain
  • Unichain
  • Berachain
  • Ink
  • MonadTestnet

Use get_supported_chains to see the complete current list.

Security Features

  • Private keys never leave your device
  • All transaction signing happens locally
  • No sensitive data transmitted to servers
  • MEV protection for Ethereum transactions
  • Private mempool routing to prevent front-running

Community & Support

For help and support, join the community:

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "defi-trading" '{"command":"npx","args":["defi-trading-mcp"],"env":{"USER_PRIVATE_KEY":"your_private_key_here","USER_ADDRESS":"0xYourWalletAddress","COINGECKO_API_KEY":"CG-your_coingecko_api_key","ALCHEMY_API_KEY":"your_alchemy_api_key"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

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.

Adding an MCP server to Cursor globally

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": {
        "defi-trading": {
            "command": "npx",
            "args": [
                "defi-trading-mcp"
            ],
            "env": {
                "USER_PRIVATE_KEY": "your_private_key_here",
                "USER_ADDRESS": "0xYourWalletAddress",
                "COINGECKO_API_KEY": "CG-your_coingecko_api_key",
                "ALCHEMY_API_KEY": "your_alchemy_api_key"
            }
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

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

2. Add this to your configuration file:

{
    "mcpServers": {
        "defi-trading": {
            "command": "npx",
            "args": [
                "defi-trading-mcp"
            ],
            "env": {
                "USER_PRIVATE_KEY": "your_private_key_here",
                "USER_ADDRESS": "0xYourWalletAddress",
                "COINGECKO_API_KEY": "CG-your_coingecko_api_key",
                "ALCHEMY_API_KEY": "your_alchemy_api_key"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later