UNPKG

@claudium/solana-mcp-server

Version:

MCP server for Solana blockchain interaction via Solscan Pro API

195 lines (163 loc) • 7.54 kB
# 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