mcp-solana-ico

GitHub Pages documentation

Project Description

MCP Solana ICO Server

This project provides a simplified example of an MCP (Model Context Protocol) server for a Solana ICO (Initial Coin Offering). It demonstrates core concepts for building an MCP server that interacts with the Solana blockchain, including:

Disclaimer: This is a simplified example and is not intended for production use. A real-world ICO would require significantly more complexity, rigorous security measures, thorough error handling, and professional auditing. This project is for educational purposes and to demonstrate the basic structure of an MCP server interacting with Solana.

Requirements

Installation

  1. Clone the repository:

    bash git clone <repository_url> cd <repository_directory>

  2. Install dependencies:

    bash poetry install

  3. Set up a Solana environment:

Configuration

.env file

The server uses environment variables for configuration. Create a .env file in the root directory with the following content:

RPC_ENDPOINT="http://localhost:8899"  # Your Solana RPC endpoint
TOKEN_MINT_ADDRESS="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"  # Replace with your actual token mint address
ICO_START_TIMESTAMP=0  # Example: Unix timestamp for ICO start
ICO_END_TIMESTAMP=0  # Example: Unix timestamp for ICO end
TOKEN_PRICE_PER_LAMPORTS=0.000001  # Default fixed price (if used)
ICO_WALLET_SEED="1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1" # Replace with a secure method in production!
CURVE_TYPE="fixed"  # Can be fixed, linear, exponential, sigmoid, or custom
FIXED_PRICE=0.000001  # Only used if CURVE_TYPE is fixed
INITIAL_PRICE=0.0000001 # Only used if CURVE_TYPE is not fixed
SLOPE=0.000000001   # Only used if CURVE_TYPE is linear
GROWTH_RATE=0.0000000001  # Only used if CURVE_TYPE is exponential
CUSTOM_FORMULA="initial_price + slope * total_tokens_minted"  # Only used if CURVE_TYPE is custom
ICO_IDS="main_ico,secondary_ico" # Comma-separated list of ICO IDs
SELL_FEE_PERCENTAGE=0.02
RATE_LIMIT_PER_MINUTE=10

Important: The ICO_WALLET_SEED is used here for demonstration purposes only. Never hardcode private keys in a production environment. Use a secure method like environment variables, a secrets manager (AWS Secrets Manager, HashiCorp Vault), or a dedicated key management system.

ICO Configurations (ico_configs/)

ICO configurations are stored as JSON files in the ico_configs/ directory. The server loads all .json files from this directory on startup. Each file represents a single ICO.

Example (ico_configs/main_ico.json):

{
  "token": {
    "name": "My Main Token",
    "symbol": "MMT",
    "total_supply": 1000000000,
    "decimals": 9
  },
  "ico": {
    "ico_id": "main_ico",
    "start_time": 1704067200,
    "end_time": 1735689600,
    "curve_type": "linear",
    "initial_price": 0.000001,
    "slope": 0.00000001,
    "sell_fee_percentage": 0.01
  },
  "resources": []
}

Example (ico_configs/secondary_ico.json):

{
    "token":{
      "name": "Secondary Token",
      "symbol": "SCT",
      "total_supply": 500000,
      "decimals": 6
   },
   "ico":{
      "ico_id":"secondary_ico",
      "start_time":1706745600,
      "end_time":1738368000,
      "curve_type":"fixed",
      "fixed_price":0.000005,
      "sell_fee_percentage":0.03
   },
   "resources":[]
}

Fields:

Usage

  1. Start the server:

    bash poetry run python mcp_solana_ico/server.py

  2. Interact with the server using an MCP client: (e.g., the Claude Desktop App or a custom client).

MCP Resources and Tools

Resources

Tools

Action API

The Action API allows the server to be integrated with Solana Blinks. Note: The affiliate program is handled by a separate server (mcp_solana_affiliate), so the Action API here does not include any affiliate-related functionality.

Project Structure

mcp-solana-ico/           # Main project directory
├── mcp_solana_ico/       # Core ICO server package
│   ├── actions.py        # Action API endpoints
│   ├── errors.py         # Custom exception classes
│   ├── server.py         # Main ICO server code
│   ├── schemas.py        # Pydantic models for data validation
│   ├── utils.py          # Utility functions
│   └── __init__.py
├── plans/                # Planning documents
├── tests/                # Tests
├── .env                  # Environment variables for ICO server
├── .gitignore
├── LICENSE
├── pyproject.toml        # Poetry configuration for main project
├── pytest.ini            # Pytest configuration
└── README.md             # This file

Key Improvements and Explanations

Future Considerations

Source Code

View the repository on GitHub.