@claudium/solana-mcp-server
Version:
MCP server for Solana blockchain interaction via Solscan Pro API
195 lines (163 loc) ⢠7.54 kB
Markdown
# CLAUDE.md - Solana MCP Server Development Guide
## šÆ Project Overview
Building a modular MCP server for Solana blockchain interaction using Solscan Pro API v2.0.
**API Documentation**: https://pro-api.solscan.io/pro-api-docs/v2.0/reference/
**API Key**: Store your Solscan Pro API key in .env as SOLANA_API_KEY
Get your key at: https://pro-api.solscan.io/
## š Solscan Pro API Categories
1. **Account APIs** - Wallet/account operations
2. **Token APIs** - Token data and analytics
3. **NFT APIs** - NFT collections and activities
4. **Transaction APIs** - Transaction details and history
5. **Block APIs** - Block information
6. **Market APIs** - Market data and liquidity pools
7. **Program APIs** - Program and platform data
8. **Monitoring APIs** - API usage monitoring
9. **Chain Information** - Blockchain statistics
## šļø Approved Project Structure
```
solana-mcp-server/
āāā providers/
ā āāā solscan/
ā ā āāā base.py # Solscan base client with API key
ā ā āāā endpoints.py # All endpoint URLs
ā ā āāā client.py # Main Solscan client
ā āāā ...existing providers (dexscreener, jupiter)
ā
āāā tools/
āāā account/ # š WALLET/ACCOUNT OPERATIONS
ā āāā account_info.py # Get account details and SOL balance
ā āāā account_tokens.py # List all tokens in wallet
ā āāā account_portfolio.py # Complete portfolio value & breakdown
ā āāā account_transactions.py # Transaction history
ā āāā account_defi.py # DeFi activities & positions
ā āāā account_staking.py # Staking info & rewards
ā āāā account_transfers.py # Transfer history & exports
ā
āāā token/ # šŖ TOKEN OPERATIONS
ā āāā token_info.py # Token metadata, supply, price
ā āāā token_holders.py # Top holders list
ā āāā token_markets.py # Trading pairs & liquidity
ā āāā token_price.py # Current & historical prices
ā āāā token_trending.py # Trending tokens
ā āāā token_latest.py # New token launches
ā āāā token_transfers.py # Token transfer activity
ā
āāā market/ # š MARKET DATA
ā āāā market_overview.py # Overall market stats
ā āāā market_volume.py # Volume leaders & stats
ā āāā liquidity_pools.py # Pool information
ā āāā top_gainers.py # Top gainers/losers
ā
āāā transaction/ # š TRANSACTION TOOLS
ā āāā tx_details.py # Transaction details & decoding
ā āāā tx_latest.py # Latest transactions
ā āāā tx_simulate.py # Simulate transactions
ā
āāā nft/ # šØ NFT TOOLS
ā āāā nft_collections.py # Collection info
ā āāā nft_activities.py # NFT trading activity
ā āāā nft_new.py # New NFT launches
ā
āāā defi/ # š° DEFI ANALYTICS
ā āāā defi_positions.py # User DeFi positions
ā āāā defi_yields.py # Yield farming opportunities
ā āāā defi_activities.py # DeFi transaction history
ā
āāā analytics/ # š ADVANCED ANALYTICS
āāā whale_tracker.py # Whale movements
āāā leaderboard.py # Top traders/accounts
āāā chain_stats.py # Blockchain statistics
```
## š Implementation Priority Order
### Phase 1 - Core Tools (COMPLETED ā
)
1. ā
Basic structure created (token_info, trending, calculator)
2. ā
`token_info` - Upgraded to Solscan API with comprehensive data
3. ā
`account_tokens` - List all tokens in wallet with balances
4. ā
`account_portfolio` - Complete portfolio analysis
5. ā
`token_trending` - Find trending tokens with Solscan
6. ā
`token_price` - Get token prices (supports single/batch queries)
### Phase 2 - Trading Tools
7. ā³ `token_holders` - See top holders
8. ā³ `market_volume` - Volume leaders
9. ā³ `account_transactions` - Transaction history
10. ā³ `token_transfers` - Token movement tracking
11. ā³ `liquidity_pools` - Pool information
### Phase 3 - Advanced Features
12. ā³ `defi_positions` - DeFi tracking
13. ā³ `whale_tracker` - Whale movements
14. ā³ `nft_collections` - NFT data
15. ā³ `account_staking` - Staking rewards
## š¬ Tool Description Standards
Each tool MUST have:
1. **Clear natural language description** for the MCP tool decorator
2. **Detailed parameter descriptions** with examples
3. **User-friendly error messages**
4. **Formatted response** for easy reading
Example:
```python
@mcp.tool()
async def get_token_info(token_address: str) -> Dict[str, Any]:
"""
Get complete information about any Solana token including price, market cap,
holders count, and liquidity. Works with token addresses like
'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' for USDC.
Args:
token_address: Solana token mint address (e.g., USDC: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v)
Returns:
Token name, symbol, price, market cap, holders, liquidity, 24h change
"""
```
## š§ Technical Requirements
### Caching Strategy
- Token prices: 30 seconds
- Account data: 60 seconds
- Trending/Latest: 5 minutes
- NFT/Historical: 10 minutes
### Error Handling
- User-friendly messages (no technical jargon)
- Fallback to cached data when API fails
- Suggest alternatives when data unavailable
### Response Format
- Clean, readable JSON
- Include source attribution
- Add helpful context (% changes, rankings)
## š Current Status
**Server Configuration**:
- ā
MCP server created and connected to Claude Code
- ā
Project-level configuration in `.mcp.json`
- ā
Environment variables configured in `.env`
- ā
Solscan Pro API v2.0 integrated with authentication
**Completed Phase 1 Tools** (January 29, 2025):
- ā
**Token Tools**:
- `get_solana_token_info` - Complete token data with price, market cap, holders
- `get_token_prices` - Single and batch price queries (up to 100 tokens)
- `get_solana_trending_tokens` - Trending tokens with sorting options
- ā
**Account Tools**:
- `get_wallet_tokens` - All tokens in wallet with balances and values
- `get_wallet_portfolio` - Complete portfolio analysis with DeFi and activity
- ā
**Legacy Tools** (backward compatibility):
- Calculator, search, and original token info still available
**Next Steps**:
1. Implement Phase 2 trading tools (holders, volume, transactions)
2. Add market data and liquidity pool tools
3. Implement DeFi and NFT analytics
4. Add comprehensive caching and error handling
## š Important Notes
- **API Key**: Stored in `.env` as `SOLANA_API_KEY`
- **Base URL**: `https://pro-api.solscan.io/v2.0/`
- **Rate Limits**: Check API documentation for limits
- **Testing**: Use USDC (EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v) for testing
## š ļø Development Commands
```bash
# Run server
python solana-mcp-server/server.py
# Test basic functionality
python solana-mcp-server/test_basic.py
# Check MCP connection
claude mcp list
# View logs
tail -f ~/.claude/logs/mcp.log
```
---
**Last Updated**: Initial setup with basic tools complete, ready for Solscan integration