-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall-mcpb.sh
More file actions
executable file
·155 lines (130 loc) · 4.03 KB
/
install-mcpb.sh
File metadata and controls
executable file
·155 lines (130 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
set -e
echo "CIDX MCPB Installation Script"
echo "=================================="
echo ""
# Validate parameters
if [ $# -ne 3 ]; then
echo "Error: Missing required parameters"
echo ""
echo "Usage: bash install-mcpb.sh SERVER_URL USERNAME PASSWORD"
echo ""
echo "Example:"
echo " curl -fsSL https://raw.githubusercontent.com/jsbattig/code-indexer/master/install-mcpb.sh | bash -s -- \"https://linner.ddns.net:8383\" \"admin\" \"admin\""
echo ""
exit 1
fi
# Accept parameters
SERVER_URL="$1"
USERNAME="$2"
PASSWORD="$3"
echo "Configuration:"
echo " Server URL: $SERVER_URL"
echo " Username: $USERNAME"
echo ""
# Check if running as correct user
if [ "$USER" != "seba.battig" ]; then
echo "Error: Must run as seba.battig user"
echo "Switch with: sudo su seba.battig"
exit 1
fi
# Set installation directory
INSTALL_DIR="$HOME/Dev/code-indexer"
echo "Installation directory: $INSTALL_DIR"
# Clone or update repository
if [ -d "$INSTALL_DIR" ]; then
echo "Updating existing repository..."
cd "$INSTALL_DIR"
git pull
else
echo "Cloning repository..."
mkdir -p "$HOME/Dev"
cd "$HOME/Dev"
git clone https://github.com/jsbattig/code-indexer.git
cd code-indexer
fi
# Install dependencies (Mac doesn't need --break-system-packages)
echo "Installing dependencies..."
pip3 install -e .
# Verify mcpb command
echo "Verifying installation..."
if ! python3 -m code_indexer.mcpb --help > /dev/null 2>&1; then
echo "Installation verification failed"
exit 1
fi
# Create ~/.mcpb directory
echo "Creating ~/.mcpb directory..."
mkdir -p "$HOME/.mcpb"
# Create wrapper script
echo "Creating wrapper script at ~/.mcpb/mcpb-wrapper.sh..."
cat > "$HOME/.mcpb/mcpb-wrapper.sh" << 'EOF'
#!/bin/bash
# MCPB Wrapper Script - Sets required environment for Claude Desktop
export HOME=/Users/seba.battig
export PYTHONPATH=/Users/seba.battig/Dev/code-indexer/src:/Users/seba.battig/Library/Python/3.9/lib/python/site-packages
export PYTHONUNBUFFERED=1
# Execute mcpb with all arguments
exec python3 -m code_indexer.mcpb "$@"
EOF
# Make wrapper executable
chmod +x "$HOME/.mcpb/mcpb-wrapper.sh"
echo "Wrapper script created and made executable"
# Update Claude Desktop config
CLAUDE_CONFIG_DIR="$HOME/Library/Application Support/Claude"
CLAUDE_CONFIG_FILE="$CLAUDE_CONFIG_DIR/claude_desktop_config.json"
echo "Updating Claude Desktop config..."
mkdir -p "$CLAUDE_CONFIG_DIR"
# Create or update config with wrapper script
cat > "$CLAUDE_CONFIG_FILE" << EOF
{
"mcpServers": {
"code-indexer": {
"command": "$HOME/.mcpb/mcpb-wrapper.sh"
}
}
}
EOF
echo "Claude Desktop config updated"
# Set up encrypted credentials using Python
echo "Setting up encrypted credentials ($USERNAME/[hidden])..."
python3 << PYTHON_SCRIPT
import sys
sys.path.insert(0, '/Users/seba.battig/Dev/code-indexer/src')
from code_indexer.mcpb.credential_storage import save_credentials
try:
save_credentials('$USERNAME', '$PASSWORD')
print("Encrypted credentials saved successfully")
except Exception as e:
print(f"Error saving credentials: {e}")
sys.exit(1)
PYTHON_SCRIPT
if [ $? -ne 0 ]; then
echo "Failed to set up encrypted credentials"
exit 1
fi
# Create ~/.mcpb/config.json with server URL
echo "Creating ~/.mcpb/config.json with server URL..."
cat > "$HOME/.mcpb/config.json" << EOF
{
"server_url": "$SERVER_URL"
}
EOF
echo "Config file created: ~/.mcpb/config.json"
# Restart Claude Desktop
echo "Restarting Claude Desktop..."
killall Claude 2>/dev/null || true
sleep 2
open -a Claude
echo ""
echo "Installation complete!"
echo ""
echo "Configuration summary:"
echo " - Server URL: $SERVER_URL"
echo " - Username: $USERNAME"
echo " - Wrapper script: $HOME/.mcpb/mcpb-wrapper.sh"
echo " - Claude config: $CLAUDE_CONFIG_FILE"
echo " - MCPB config: ~/.mcpb/config.json"
echo " - Credentials: ~/.mcpb/credentials.enc (encrypted)"
echo ""
echo "Claude Desktop has been restarted and should now have MCPB server available."
echo "Check Claude Desktop's server panel to verify the code-indexer MCP server is connected."