dexscreener-mcp-server

Malomalsky/dexscreener-mcp-server

3.2

If you are the rightful owner of dexscreener-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

DexScreener MCP Server is a production-ready Model Context Protocol server designed for seamless integration with the DexScreener API, providing fast, reliable, and developer-friendly access to DeFi data.

Tools
5
Resources
0
Prompts
0

DexScreener MCP Server

Python 3.9+ License: MIT Code style: black Ruff Type checked: mypy

Production-ready Model Context Protocol server for DexScreener API

Quick Start โ€ข Documentation โ€ข Development โ€ข Features


Why This MCP Server?

Built for Production: Enterprise-grade error handling, rate limiting, and monitoring
Lightning Fast: Intelligent caching, async architecture, and optimized API calls
Rock Solid: Comprehensive testing, type safety, and bulletproof error handling
Developer Friendly: Beautiful APIs, extensive docs, and smooth developer experience


Features

Complete DexScreener API Integration

  • Token information and trading pairs
  • Pair details and analytics
  • Search functionality
  • Trending pairs discovery
  • Multi-pair batch requests

Production-Ready Architecture

  • Comprehensive error handling
  • Rate limiting (300 req/min by default)
  • Intelligent caching with TTL
  • Automatic retries with exponential backoff
  • Input validation with Pydantic

Monitoring & Observability

  • Structured logging with structlog
  • Request/response tracking
  • Performance metrics
  • Error analytics

Developer Experience

  • Full type safety with comprehensive annotations
  • Beautiful async/await API
  • Extensive documentation
  • Easy configuration
  • Development-friendly setup

Quick Start

Installation

# Clone the repository
git clone https://github.com/Malomalsky/dexscreener-mcp-server.git
cd dexscreener-mcp-server

# Standard installation
pip install -e .

# For development
pip install -e ".[dev]"

# If you have FastAPI compatibility issues
pip install -e ".[fastapi-compat]"

Dependency Conflicts

If you encounter dependency conflicts with FastAPI or other packages:

# Option 1: Use virtual environment (recommended)
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e .

# Option 2: Force installation (may cause issues)
pip install -e . --force-reinstall

# Option 3: Use compatibility mode
pip install -e ".[fastapi-compat]"

# Option 4: Standalone minimal installation
python standalone_install.py

Configuration

# Copy example environment file
cp .env.example .env

# Edit configuration (optional - works great with defaults!)
nano .env

Running the Server

โš ๏ธ Important: This is an MCP (Model Context Protocol) server designed to run within MCP-enabled applications. It cannot be used standalone.

# Test the server installation
python -c "from dexscreener_mcp.server import DexScreenerMCPServer; print('โœ… Server ready!')"

# The server will be automatically started by MCP clients
# Do NOT run these commands directly unless testing:
# python -m dexscreener_mcp.server  # Will wait for MCP protocol input

How it works: MCP applications (Claude Desktop, Cursor, etc.) will automatically start and communicate with this server using the stdio protocol.

Integration with Applications

โš ๏ธ MCP Support Status:

  • โœ… Claude Desktop: Full native support
  • ๐Ÿงช Cursor IDE: Experimental/limited support
  • ๐Ÿงช Zed Editor: Experimental support
  • ๐Ÿงช VS Code: Requires MCP extension
  • โ“ Continue.dev: Support may vary
Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "dexscreener": {
      "command": "python",
      "args": ["-m", "dexscreener_mcp.server"],
      "env": {}
    }
  }
}

Config file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json
Cursor IDE
  1. Install MCP support in Cursor (if available)
  2. Add server configuration in Cursor settings (settings.json):

Option 1 (Recommended - Claude Desktop format):

{
  "mcpServers": {
    "dexscreener": {
      "command": "python",
      "args": ["-m", "dexscreener_mcp.server"],
      "env": {}
    }
  }
}

Option 2 (Alternative format):

{
  "mcp": {
    "servers": {
      "dexscreener": {
        "command": "python",
        "args": ["-m", "dexscreener_mcp.server"]
      }
    }
  }
}

Option 3 (Full Python path for Windows):

{
  "mcpServers": {
    "dexscreener": {
      "command": "C:\\Users\\YourUser\\AppData\\Local\\Programs\\Python\\Python311\\python.exe",
      "args": ["-m", "dexscreener_mcp.server"],
      "env": {}
    }
  }
}
  1. Configuration Location:

    • Windows: %APPDATA%\Cursor\User\settings.json
    • macOS: ~/Library/Application Support/Cursor/User/settings.json
    • Linux: ~/.config/Cursor/User/settings.json
  2. Troubleshooting:

    • Step 1: Verify installation: python -c "import dexscreener_mcp; print('โœ… OK')"
    • Step 2: Test server manually: python -m dexscreener_mcp.server
    • Step 3: Add configuration to Cursor settings.json
    • Step 4: Completely restart Cursor (important!)
    • Step 5: Check Cursor's Output panel โ†’ MCP for error messages
    • Step 6: Look for "dexscreener" in Cursor's MCP server list

    If "0 tools enabled":

    • Use absolute Python path in config (see Option 3)
    • Check if Python is in PATH: python --version
    • Try running debug script: python debug_cursor.py
  3. Expected behavior: Server will show "โณ Waiting for MCP client connection..." when working correctly

Note: MCP support in Cursor may be experimental. If none of these work, MCP might not be fully supported yet.

Zed Editor

Add to Zed settings (~/.config/zed/settings.json):

{
  "assistant": {
    "version": "2",
    "provider": {
      "name": "openai",
      "api_url": "https://api.openai.com/v1"
    }
  },
  "experimental": {
    "mcp_servers": {
      "dexscreener": {
        "command": "python",
        "args": ["-m", "dexscreener_mcp.server"]
      }
    }
  }
}

Alternative format:

{
  "mcp": {
    "servers": {
      "dexscreener": {
        "command": "python",
        "args": ["-m", "dexscreener_mcp.server"]
      }
    }
  }
}

Note: MCP support in Zed is experimental and may require specific Zed versions.

Continue.dev

Add to Continue configuration (~/.continue/config.json):

{
  "models": [...],
  "mcpServers": {
    "dexscreener": {
      "command": "python",
      "args": ["-m", "dexscreener_mcp.server"]
    }
  }
}

Alternative format:

{
  "models": [...],
  "mcp": {
    "servers": {
      "dexscreener": {
        "command": "python",
        "args": ["-m", "dexscreener_mcp.server"]
      }
    }
  }
}

Note: MCP support in Continue.dev may vary by version.

VS Code
  1. Install MCP extension for VS Code (if available)
  2. Add to workspace settings (.vscode/settings.json):

Option 1:

{
  "mcpServers": {
    "dexscreener": {
      "command": "python",
      "args": ["-m", "dexscreener_mcp.server"],
      "env": {}
    }
  }
}

Option 2:

{
  "mcp": {
    "servers": {
      "dexscreener": {
        "command": "python",
        "args": ["-m", "dexscreener_mcp.server"]
      }
    }
  }
}

Note: MCP support in VS Code requires specific extensions and may be limited.

GitHub Codespaces

Works out of the box! Just install the package:

pip install -e .

Then use with any MCP-enabled extension in Codespaces.

Custom MCP Client

For custom implementations, use the MCP SDK:

from mcp import ClientSession
import asyncio

async def main():
    async with ClientSession("dexscreener-mcp") as session:
        # List available tools
        tools = await session.list_tools()
        
        # Call a tool
        result = await session.call_tool(
            "search_tokens", 
            {"query": "USDC", "limit": 10}
        )
        print(result)

asyncio.run(main())

Example Usage

# Through any MCP-enabled application:
"Get token information for USDC"
"Search for trending Ethereum pairs" 
"Find information about Uniswap V3 WETH/USDC pair"
"Show me the top 5 trending pairs on Base network"
"What's the current price and volume for PEPE token?"

Available Tools

ToolDescriptionExample
get_token_infoGet comprehensive token data and trading pairs{"token_address": "0xA0b86a33E6Fe17D51f8C62C7B4E8CC38F8D5A0D8"}
get_pair_infoDetailed trading pair analytics with price, volume, liquidity{"chain_id": "ethereum", "pair_address": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640"}
search_tokensSmart token search by name, symbol, or address{"query": "PEPE", "limit": 20}
get_trending_pairsDiscover hot and trending pairs on any blockchain{"chain_id": "base"}
get_multiple_pairsBatch requests for multiple pairs efficiently{"pair_addresses": ["ethereum:0x...", "bsc:0x..."]}
get_supported_chainsList all supported blockchain networks{}
get_rate_limit_infoCheck current API rate limit status{}

Response Examples

Token Search Example
{
  "tool": "search_tokens",
  "query": "USDC",
  "response": {
    "pairs": [
      {
        "chainId": "ethereum",
        "dexId": "uniswap",
        "url": "https://dexscreener.com/ethereum/0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
        "pairAddress": "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640",
        "baseToken": {
          "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "name": "Wrapped Ether",
          "symbol": "WETH"
        },
        "quoteToken": {
          "address": "0xa0b86a33e6fe17d51f8c62c7b4e8cc38f8d5a0d8",
          "name": "USD Coin",
          "symbol": "USDC"
        },
        "priceUsd": "3456.78",
        "volume": {
          "h24": 145000000
        }
      }
    ]
  }
}
Trending Pairs Example
{
  "tool": "get_trending_pairs",
  "chain_id": "base",
  "response": {
    "pairs": [
      {
        "chainId": "base",
        "dexId": "uniswap",
        "priceUsd": "0.000024",
        "priceChange": {
          "h24": 156.7
        },
        "volume": {
          "h24": 2400000
        },
        "marketCap": 12000000
      }
    ]
  }
}

Architecture & Design

graph TB
    A[Claude/MCP Client] --> B[DexScreener MCP Server]
    B --> C[Rate Limiter]
    C --> D[Cache Layer]
    D --> E[HTTP Client]
    E --> F[DexScreener API]
    
    B --> G[Error Handler]
    B --> H[Type Validator]
    B --> I[Logger]
    
    style A fill:#e1f5fe
    style B fill:#f3e5f5
    style F fill:#e8f5e8

Project Structure

dexscreener_mcp/
โ”œโ”€โ”€ __init__.py          # Package initialization & exports
โ”œโ”€โ”€ server.py            # MCP server implementation
โ”œโ”€โ”€ client.py            # DexScreener API client with all features
โ””โ”€โ”€ types.py             # Pydantic models & type definitions

Key Components

ComponentDescriptionFeatures
DexScreenerMCPServerMain MCP serverTool routing, Error handling, Logging
DexScreenerClientAPI clientRate limiting, Caching, Retries
Pydantic ModelsType safetyValidation, Serialization, Documentation
Error SystemException handlingUser-friendly errors, Monitoring, Debugging

Configuration Options

VariableDefaultDescriptionRecommendation
DEXSCREENER_RATE_LIMIT300Requests per minuteKeep default for best performance
DEXSCREENER_CACHE_TTL60Cache TTL in secondsIncrease for less volatile data
DEXSCREENER_TIMEOUT30Request timeout in secondsGood for most networks
DEXSCREENER_MAX_RETRIES3Maximum retry attemptsIncrease for unstable connections
LOG_LEVELINFOLogging verbosityUse DEBUG for development
LOG_FORMATjsonLog formatjson for production, text for dev

Example Configuration

# .env file
DEXSCREENER_RATE_LIMIT=300      # Respectful rate limiting
DEXSCREENER_CACHE_TTL=60        # Fast responses with smart caching  
DEXSCREENER_TIMEOUT=30          # Reasonable timeout
DEXSCREENER_MAX_RETRIES=3       # Resilient error handling
LOG_LEVEL=INFO                  # Balanced logging
LOG_FORMAT=json                 # Structured logs for monitoring

Development

Setup Development Environment

# Install development dependencies
pip install -e ".[dev]"

# Install pre-commit hooks for automated quality checks
pre-commit install

# Run tests with coverage
pytest --cov=dexscreener_mcp --cov-report=html

# Run the full quality check suite
make lint    # or run manually below

Manual Quality Checks

# Code formatting
black dexscreener_mcp/
isort dexscreener_mcp/

# Linting
ruff check dexscreener_mcp/ --fix

# Type checking  
mypy dexscreener_mcp/

# Testing
pytest tests/ -v

Code Quality Standards

This project follows enterprise-grade standards:

ToolPurposeConfig
BlackCode formattingline-length = 88
isortImport sortingprofile = "black"
RuffFast lintingtarget-version = "py39"
mypyType checkingstrict = true
pytestTesting frameworkasyncio_mode = "auto"
pre-commitQuality gatesAutomated on commit

API Reference & Supported Networks

Supported Blockchains

NetworkChain IDNative TokenExplorer
EthereumethereumETHetherscan.io
BNB Smart ChainbscBNBbscscan.com
PolygonpolygonMATICpolygonscan.com
ArbitrumarbitrumETHarbiscan.io
OptimismoptimismETHoptimistic.etherscan.io
BasebaseETHbasescan.org
AvalancheavalancheAVAXsnowtrace.io
FantomfantomFTMftmscan.com

And 20+ more networks supported!

Response Models

All API responses are validated using Pydantic v2 models:

# Token Information
class TokenResponse:
    pairs: List[PairInfo]  # All trading pairs for token

# Trading Pair Details  
class PairResponse:
    pair: Optional[PairInfo]  # Detailed pair information

# Search Results
class SearchResult:
    pairs: List[PairInfo]  # Matching pairs from search

# Trending Data
class TrendingResponse:
    pairs: List[PairInfo]  # Hot/trending pairs

Error Handling

Error TypeHandling StrategyUser Experience
API ErrorsStructured error parsingClear, actionable error messages
Network IssuesExponential backoff retryAutomatic recovery, no interruption
Rate LimitsIntelligent throttlingSmooth operation within limits
ValidationPydantic model validationType-safe, validated responses
TimeoutsConfigurable timeoutsPredictable response times

Performance & Optimization

Speed Features

  • Smart Caching: TTL-based response caching
  • Rate Limiting: Respectful 300 req/min default
  • Connection Pooling: Efficient HTTP client reuse
  • Async Architecture: Non-blocking I/O operations
  • Batch Processing: Multi-pair requests in single call

Performance Metrics

# Typical response times (with cache miss)
Token Info:        ~200ms
Pair Details:      ~150ms  
Search Results:    ~300ms
Trending Pairs:    ~250ms

# With cache hit: ~5-10ms
# Rate limit overhead: ~0ms (smart queuing)

Contributing

We welcome contributions! Here's how to get started:

Quick Contribution Guide

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Run quality checks (pre-commit run --all-files)
  5. Commit with descriptive messages
  6. Push to your branch
  7. Open a Pull Request

Contribution Checklist

  • Code follows project style (Black, isort, Ruff)
  • Tests added for new functionality
  • Documentation updated if needed
  • Type hints added for new code
  • Performance impact considered
  • Security implications reviewed

Useful Links


License

This project is licensed under the MIT License - see the file for details.

Acknowledgments

Special thanks to:

  • DexScreener for the excellent DeFi data API
  • Model Context Protocol for the amazing MCP framework
  • Python Community for incredible libraries and tools
  • Anthropic for Claude and MCP innovation

Built with enterprise standards โ€ข Production ready โ€ข Type safe โ€ข Resilient โ€ข Monitored

Star this repo if it helped you build amazing DeFi tools!