mcp-solana-dex

GitHub Pages documentation

Project Description

MCP Solana DEX Server

This directory contains a a simple Decentralized Exchange (DEX) MCP server.

Purpose

This server provides basic DEX functionalities for tokens associated with ICOs managed by the main server:

Features

Disclaimer: This is a simplified example. The execute_order tool performs server-side pre-condition checks (buyer SOL balance, seller token balance) before updating the internal order book. It does NOT execute the on-chain atomic swap. Clients interacting with this server are responsible for constructing and submitting the actual atomic swap transaction after receiving a success response from execute_order. This is NOT suitable for production without a robust client-side atomic swap implementation.

Configuration (./.env)

Create a .env file in this directory (./) with the following:

# Configuration for MCP Solana DEX Sub-project

# Solana RPC Endpoint (use the same as the main project or specify a different one)
RPC_ENDPOINT="http://localhost:8899"

# Path to the order book data file (relative to this directory)
ORDER_BOOK_FILE="data/order_book.json"

# Optional: Define the token mint address if needed globally
# TOKEN_MINT_ADDRESS="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"

Usage

This server is intended to be run as a separate process from the main ICO server.

  1. Ensure Dependencies: Make sure dependencies are installed (likely managed by the parent project's poetry install).
  2. Navigate to Parent Directory: Open your terminal in the main project root.
  3. Start the DEX Server:

    bash poetry run python mcp_solana_dex/server.py

  4. Interact: Use an MCP client connected to the standard input/output of this process.

MCP Tools

Testing

This project uses pytest for integration testing. The tests primarily call the server's tool functions directly, mocking necessary external interactions (like Solana RPC calls) to verify the server's internal logic and state management.

  1. Install Development Dependencies: Make sure you have the main dependencies installed, then install the development dependencies which include pytest and pytest-asyncio:

    ```bash

    Navigate to the project root directory (where pyproject.toml is)

    poetry install --with dev ```

  2. Run Tests: Execute pytest from the project root directory:

    bash poetry run pytest

    Pytest will automatically discover and run the tests located in the tests/ directory.

Future Considerations

Source Code

View the repository on GitHub.