GitHub Pages documentation
This directory contains a a simple Decentralized Exchange (DEX) MCP server.
This server provides basic DEX functionalities for tokens associated with ICOs managed by the main server:
create_order, cancel_order, execute_order, get_orders).data/order_book.json by default).ico_ids.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.
./.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"
This server is intended to be run as a separate process from the main ICO server.
poetry install).Start the DEX Server:
bash
poetry run python mcp_solana_dex/server.py
Interact: Use an MCP client connected to the standard input/output of this process.
create_order: Creates a new sell order.ico_id: (String) The ID of the ICO for the token.amount: (Integer) Amount of tokens to sell (base units).price: (Float) Price per token in SOL.owner: (String) Public key of the seller.cancel_order: Cancels an existing order.ico_id: (String) The ID of the ICO.order_id: (String) The unique ID of the order to cancel.owner: (String) Public key of the seller (must match order).execute_order: Performs pre-condition checks for executing a sell order and updates the internal order book if checks pass. Does not execute the on-chain swap.ico_id: (String) The ID of the ICO.order_id: (String) The ID of the order to buy from.buyer: (String) Public key of the buyer.amount: (Integer) Amount of tokens to buy (base units).token_mint_address: (String) Mint address of the token.token_decimals: (Integer) Decimals of the token.get_orders: Retrieves the current sell orders for an ICO.ico_id: (String) The ID of the ICO.limit: (Integer, optional) Max orders to return (default 100).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.
Install Development Dependencies:
Make sure you have the main dependencies installed, then install the development dependencies which include pytest and pytest-asyncio:
```bash
poetry install --with dev ```
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.
View the repository on GitHub.