SolanaMcpService
The Solana MCP Server is designed to facilitate interactions between AI models and the Solana blockchain, providing REST APIs and WebSocket services for real-time blockchain operations. It offers features such as secure transactions, real-time updates, and custom token creation.
Solana MCP (Model Context Protocol) Server
This is an MCP server that allows large language models (LLMs) like Claude to interact with the Solana blockchain. The service provides a set of APIs and WebSocket interfaces that enable AI models to perform operations such as querying balances, sending tokens, retrieving transaction history, creating custom PumpFun tokens, and more.
Live Service: The MCP service is now live and accessible at https://mcp.so/
Features
- Provides REST API endpoints for Solana blockchain interaction
- Supports WebSocket connections for real-time updates
- Includes handlers specifically designed for MCP
- Built-in HTML test interface for easy testing of all features
- Secure handling of blockchain operations
- Comprehensive error handling and logging
- Custom PumpFun token creation capability
Quick Start
Using the Deployed Service
The easiest way to get started is to use our deployed MCP service:
- Access the service at https://mcp.so/
- Use the test interface to try out the available features
- Integrate with your AI applications using the API endpoints
Self-Hosting
Prerequisites
- Node.js (v14+)
- npm or yarn
- Solana CLI tools (optional, for advanced testing)
Installation
- Clone this repository and install dependencies:
# Install dependencies
npm install
- Configure environment variables:
# Copy the example configuration file
copy .env.example .env # For Windows
# cp .env.example .env # For Linux
# Edit the .env file to set your configuration
- Start the server:
npm start
The server will run on http://localhost:3000 by default. You can visit this address to view the test interface.
Project Structure
├── src/
│ ├── controllers/ # API endpoint handlers
│ ├── services/ # Business logic
│ ├── models/ # Data models
│ ├── utils/ # Helper functions
│ ├── middleware/ # Express middleware
│ ├── mcp/ # MCP-specific handlers
│ └── index.js # Entry point
├── public/ # Static assets
├── tests/ # Test files
└── .env # Environment configuration
API Endpoints
Network Information
GET /api/network
Get the current Solana network status.
Response:
{
"status": "online",
"currentSlot": 123456789,
"network": "devnet"
}
Balance Query
GET /api/balance/:address
Get the SOL balance for a specified address.
Response:
{
"address": "B4QLphqm5gwfzpo8ibW1EmpoyQwoQybj5v7vJRvXoZn6",
"balance": 12.34,
"unit": "SOL"
}
Transaction History
GET /api/transactions/:address
Get recent transaction history for a specified address.
Response:
{
"transactions": [
{
"signature": "xxxxxxxxxxxxxxxxxxxxxx",
"timestamp": "2023-04-15T14:23:45Z",
"type": "transfer",
"amount": 1.5,
"status": "confirmed"
}
]
}
Create Wallet
POST /api/wallet/create
Create a new Solana wallet (including public and private keys).
Response:
{
"publicKey": "B4QLphqm5gwfzpo8ibW1EmpoyQwoQybj5v7vJRvXoZn6",
"secretKey": "[base58 encoded private key]"
}
Transfer SOL
POST /api/transfer
Send SOL from one address to another.
Request Body:
{
"fromSecretKey": "[base58 encoded private key]",
"toAddress": "B4QLphqm5gwfzpo8ibW1EmpoyQwoQybj5v7vJRvXoZn6",
"amount": 0.05
}
Response:
{
"transactionId": "xxxxxxxxxxxxxxxxxxxxxx",
"status": "confirmed"
}
Account Information
GET /api/account/:address
Get detailed account information for an address.
Response:
{
"address": "B4QLphqm5gwfzpo8ibW1EmpoyQwoQybj5v7vJRvXoZn6",
"lamports": 12340000000,
"executable": false,
"owner": "11111111111111111111111111111111",
"rentEpoch": 123
}
Create PumpFun Token
POST /api/mcp/execute
Create a custom PumpFun token on the Solana blockchain.
Request Body:
{
"tool": "createPumpFunToken",
"params": {
"name": "My Token Name",
"symbol": "MTN",
"description": "This is my custom token",
"twitter": "https://x.com/xxx",
"telegram": "https://t.me/xxx",
"website": "https://mywebsite.com",
"amount": "0.1",
"slippage": "10",
"priorityFee": "0.0005"
}
}
Response:
{
"success": true,
"transaction": "transaction_signature_hash",
"mint": "token_mint_address",
"metadata": "metadata_address"
}
MCP-Specific
POST /api/mcp/execute
Execute MCP-specific operations such as getting balances, retrieving transaction records, sending SOL, etc.
MCP Integration
This service is specifically designed to support AI models like Claude in interacting with the Solana blockchain. The following MCP operations are supported:
getNetworkStatus
- Get network statusgetBalance
- Query balancegetTransactions
- Get transaction historycreateWallet
- Create a new wallettransferSol
- Transfer SOLgetAccountInfo
- Get account informationcreatePumpFunToken
- Create a custom PumpFun token
Example MCP Request
{
"action": "getBalance",
"parameters": {
"address": "B4QLphqm5gwfzpo8ibW1EmpoyQwoQybj5v7vJRvXoZn6"
}
}
WebSocket Support
The server supports real-time updates and command sending via WebSocket connections. The WebSocket service runs on the same port as the HTTP server.
Connect to WebSocket at: ws://localhost:3000/ws
WebSocket Events
connect
- Connection establishedbalance
- Balance updatestransaction
- New transaction notificationserror
- Error notifications
Deployment
Recommended Settings for Production Environment
- Use PM2 or Docker for deployment
- Set appropriate environment variables
- Configure HTTPS (recommended for production)
- Set up proper logging
- Implement rate limiting for public-facing APIs
Docker Deployment
# Build the image
docker build -t solana-mcp-server .
# Run the container
docker run -p 3000:3000 -d solana-mcp-server
Linux Server Deployment
# Clone the repository
git clone [repository-url] solana-mcp-server
cd solana-mcp-server
# Install dependencies
npm install --production
# Configure environment
cp .env.example .env
nano .env # Edit as needed
# Start with PM2 (recommended for production)
npm install -g pm2
pm2 start ecosystem.config.js
# Configure PM2 to start on boot
pm2 startup
pm2 save
Troubleshooting
Common Issues
- Connection errors - Check if Solana network is reachable and verify your RPC endpoint
- Transaction failures - Ensure you have sufficient SOL for transaction fees
- API rate limiting - Check if you're hitting rate limits on the Solana RPC endpoints
- WebSocket disconnections - Implement proper reconnection logic in your client
Logs
Check the logs for detailed error information:
# If using PM2
pm2 logs
# If using Docker
docker logs [container-id]
Security Considerations
- Private key data should only be handled on the client side and should not be stored on the server
- Use HTTPS in production environments
- Consider adding appropriate authentication mechanisms
- Configure reasonable rate limits
- Regularly update dependencies to patch security vulnerabilities
- Use environment variables for sensitive configuration
Contributing
Issues and pull requests are welcome. Please follow these steps to contribute:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to your branch
- Create a pull request
License
MIT