1+ #! /bin/bash
2+ # One-liner installation script for Solana MCP Server
3+ # Usage: curl -fsSL https://raw.githubusercontent.com/opensvm/solana-mcp-server/main/scripts/install.sh | bash
4+ set -e
5+
6+ echo " 🚀 Installing Solana MCP Server for Claude Desktop..."
7+
8+ # Function to detect OS and architecture
9+ detect_platform () {
10+ local os=$( uname -s | tr ' [:upper:]' ' [:lower:]' )
11+ local arch=$( uname -m)
12+
13+ case " $arch " in
14+ x86_64) arch=" amd64" ;;
15+ arm64|aarch64) arch=" arm64" ;;
16+ * ) echo " Unsupported architecture: $arch " >&2 ; exit 1 ;;
17+ esac
18+
19+ case " $os " in
20+ darwin) os=" macos" ;;
21+ linux) os=" linux" ;;
22+ * ) echo " Unsupported OS: $os " >&2 ; exit 1 ;;
23+ esac
24+
25+ echo " ${os} -${arch} "
26+ }
27+
28+ # Function to get Claude config directory
29+ get_claude_config_dir () {
30+ if [[ " $OSTYPE " == " darwin" * ]]; then
31+ echo " $HOME /Library/Application Support/Claude"
32+ else
33+ echo " ${XDG_CONFIG_HOME:- $HOME / .config} /claude"
34+ fi
35+ }
36+
37+ # Try to download pre-built binary first, fall back to building from source
38+ try_download_binary () {
39+ local platform=$( detect_platform)
40+ local binary_name=" solana-mcp-server-${platform} "
41+
42+ echo " Attempting to download pre-built binary for ${platform} ..."
43+
44+ # Try to download from releases
45+ local download_url=" https://github.com/opensvm/solana-mcp-server/releases/latest/download/${binary_name} "
46+ if curl -sL " $download_url " -o solana-mcp-server; then
47+ # Check if download was successful (not a 404 page)
48+ if [[ $( wc -c < solana-mcp-server) -gt 1000 ]] && file solana-mcp-server | grep -q " executable" ; then
49+ chmod +x solana-mcp-server
50+ echo " ✅ Downloaded pre-built binary"
51+ return 0
52+ else
53+ echo " ⚠️ Download failed or binary not available"
54+ rm -f solana-mcp-server
55+ return 1
56+ fi
57+ else
58+ echo " ⚠️ Pre-built binary not available, building from source..."
59+ return 1
60+ fi
61+ }
62+
63+ # Build from source
64+ build_from_source () {
65+ echo " Building Solana MCP Server from source..."
66+
67+ # Check if Rust is installed
68+ if ! command -v cargo & > /dev/null; then
69+ echo " Installing Rust..."
70+ curl --proto ' =https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
71+ source " $HOME /.cargo/env"
72+ fi
73+
74+ # Clone and build
75+ TEMP_DIR=$( mktemp -d)
76+ cd " $TEMP_DIR "
77+ git clone https://github.com/opensvm/solana-mcp-server.git .
78+ cargo build --release
79+
80+ # Copy binary to working directory
81+ cp target/release/solana-mcp-server " $OLDPWD /"
82+ cd " $OLDPWD "
83+ rm -rf " $TEMP_DIR "
84+
85+ echo " ✅ Built from source successfully"
86+ }
87+
88+ # Main installation logic
89+ main () {
90+ # Create working directory
91+ INSTALL_DIR=" $HOME /.local/bin"
92+ mkdir -p " $INSTALL_DIR "
93+ cd " $INSTALL_DIR "
94+
95+ # Try download first, then build if needed
96+ if ! try_download_binary; then
97+ build_from_source
98+ fi
99+
100+ # Configure Claude Desktop
101+ local claude_config_dir=$( get_claude_config_dir)
102+ mkdir -p " $claude_config_dir "
103+
104+ local config_file=" $claude_config_dir /claude_desktop_config.json"
105+ local server_path=" $INSTALL_DIR /solana-mcp-server"
106+
107+ # Create or update Claude config
108+ if [[ -f " $config_file " ]]; then
109+ echo " ⚠️ Existing Claude config found. Backing up..."
110+ cp " $config_file " " ${config_file} .backup.$( date +%s) "
111+ fi
112+
113+ cat > " $config_file " << EOF
114+ {
115+ "mcpServers": {
116+ "solana": {
117+ "command": "$server_path ",
118+ "env": {
119+ "SOLANA_RPC_URL": "https://api.mainnet-beta.solana.com",
120+ "SOLANA_COMMITMENT": "confirmed"
121+ }
122+ }
123+ }
124+ }
125+ EOF
126+
127+ echo " ✅ Installation complete!"
128+ echo " "
129+ echo " 🎉 Solana MCP Server is now configured for Claude Desktop"
130+ echo " 📁 Installed at: $server_path "
131+ echo " ⚙️ Config file: $config_file "
132+ echo " "
133+ echo " 🚀 To use:"
134+ echo " 1. Restart Claude Desktop"
135+ echo " 2. You can now query Solana blockchain data directly in Claude!"
136+ echo " "
137+ echo " 💡 Example queries:"
138+ echo " - 'What is the balance of account [pubkey]?'"
139+ echo " - 'Show me the latest block information'"
140+ echo " - 'Get transaction details for [signature]'"
141+ echo " "
142+ echo " 📖 More info: https://github.com/opensvm/solana-mcp-server"
143+ }
144+
145+ # Run main function
146+ main " $@ "
0 commit comments