-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathverify-setup.sh
More file actions
executable file
·267 lines (237 loc) · 10.4 KB
/
verify-setup.sh
File metadata and controls
executable file
·267 lines (237 loc) · 10.4 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#!/bin/bash
# ABOUTME: Verification script for CodeGraph MCP server setup
# ABOUTME: Tests SurrealDB connection, LLM provider configuration, and MCP server health
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Configuration
SURREAL_ENDPOINT="${SURREAL_ENDPOINT:-ws://localhost:3004}"
SURREAL_HTTP_ENDPOINT="http://localhost:3004"
SURREAL_NAMESPACE="${SURREAL_NAMESPACE:-ouroboros}"
SURREAL_DATABASE="${SURREAL_DATABASE:-codegraph}"
SURREAL_USER="${SURREAL_USER:-root}"
SURREAL_PASSWORD="${SURREAL_PASSWORD:-root}"
echo -e "${BLUE}═══════════════════════════════════════════════════${NC}"
echo -e "${BLUE} CodeGraph MCP Server Verification${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════${NC}"
echo ""
# Test counter
PASSED=0
FAILED=0
test_passed() {
echo -e "${GREEN}✓ $1${NC}"
((PASSED++))
}
test_failed() {
echo -e "${RED}✗ $1${NC}"
((FAILED++))
}
test_warning() {
echo -e "${YELLOW}⚠ $1${NC}"
}
# =============================================================================
# 1. Check if SurrealDB is running
# =============================================================================
echo -e "${YELLOW}[1/6] Checking SurrealDB availability...${NC}"
if curl -sf "$SURREAL_HTTP_ENDPOINT/health" > /dev/null 2>&1; then
test_passed "SurrealDB is running on port 3004"
else
test_failed "SurrealDB is not running on port 3004"
echo " Start SurrealDB with: surreal start --bind 0.0.0.0:3004 --user root --pass root file://data/surreal.db"
fi
echo ""
# =============================================================================
# 2. Test WebSocket connection
# =============================================================================
echo -e "${YELLOW}[2/6] Testing WebSocket connection...${NC}"
# Test if we can connect via WebSocket (using curl's WebSocket upgrade)
if command -v websocat &> /dev/null; then
# Use websocat if available
if timeout 2 websocat -n1 "$SURREAL_ENDPOINT" < /dev/null 2>/dev/null; then
test_passed "WebSocket connection successful"
else
test_warning "WebSocket test inconclusive (websocat available but connection unclear)"
fi
elif command -v wscat &> /dev/null; then
# Use wscat if available
if timeout 2 wscat -c "$SURREAL_ENDPOINT" -x 'ping' 2>/dev/null | grep -q 'pong\|connected'; then
test_passed "WebSocket connection successful"
else
test_warning "WebSocket test inconclusive (wscat available but connection unclear)"
fi
else
test_warning "WebSocket testing tools not available (install websocat or wscat for full testing)"
echo " Assuming WebSocket works if HTTP health check passed"
fi
echo ""
# =============================================================================
# 3. Test SurrealDB authentication and namespace access
# =============================================================================
echo -e "${YELLOW}[3/6] Testing SurrealDB authentication and namespace...${NC}"
if command -v surreal &> /dev/null; then
# Test if we can authenticate and query
TEST_QUERY="INFO FOR DB;"
if surreal sql --endpoint "$SURREAL_HTTP_ENDPOINT" \
--namespace "$SURREAL_NAMESPACE" \
--database "$SURREAL_DATABASE" \
--auth-level root \
--username "$SURREAL_USER" \
--password "$SURREAL_PASSWORD" \
--command "$TEST_QUERY" > /dev/null 2>&1; then
test_passed "SurrealDB authentication successful"
test_passed "Namespace '$SURREAL_NAMESPACE' accessible"
test_passed "Database '$SURREAL_DATABASE' accessible"
else
test_failed "SurrealDB authentication or namespace access failed"
echo " Check credentials: username=$SURREAL_USER, namespace=$SURREAL_NAMESPACE"
fi
else
test_warning "SurrealDB CLI not installed - skipping authentication test"
echo " Install from: https://surrealdb.com/install"
fi
echo ""
# =============================================================================
# 4. Check schema tables
# =============================================================================
echo -e "${YELLOW}[4/6] Checking database schema...${NC}"
if command -v surreal &> /dev/null; then
TABLES_QUERY="SELECT * FROM schema_versions LIMIT 1;"
if surreal sql --endpoint "$SURREAL_HTTP_ENDPOINT" \
--namespace "$SURREAL_NAMESPACE" \
--database "$SURREAL_DATABASE" \
--auth-level root \
--username "$SURREAL_USER" \
--password "$SURREAL_PASSWORD" \
--command "$TABLES_QUERY" 2>&1 | grep -q "version"; then
test_passed "Schema tables exist and are accessible"
# Get schema version
VERSION=$(surreal sql --endpoint "$SURREAL_HTTP_ENDPOINT" \
--namespace "$SURREAL_NAMESPACE" \
--database "$SURREAL_DATABASE" \
--auth-level root \
--username "$SURREAL_USER" \
--password "$SURREAL_PASSWORD" \
--command "SELECT version FROM schema_versions ORDER BY version DESC LIMIT 1;" 2>&1 | grep -oP 'version.*\K\d+' | head -1)
if [ -n "$VERSION" ]; then
echo " Current schema version: $VERSION"
fi
else
test_warning "Schema tables not found - run './schema/apply-schema.sh' to initialize"
fi
else
test_warning "Cannot check schema - SurrealDB CLI not installed"
fi
echo ""
# =============================================================================
# 5. Check LLM Provider Configuration
# =============================================================================
echo -e "${YELLOW}[5/6] Checking LLM provider configuration...${NC}"
# Check for .env file
if [ -f ".env" ]; then
test_passed "Found .env configuration file"
# Check for LLM provider settings
if grep -q "CODEGRAPH_LLM_PROVIDER\|LLM_PROVIDER" .env 2>/dev/null; then
PROVIDER=$(grep -E "^(CODEGRAPH_LLM_PROVIDER|LLM_PROVIDER)=" .env | cut -d'=' -f2 | tr -d '"' | tr -d "'" | head -1)
echo " LLM Provider: ${PROVIDER:-<not set>}"
case "$PROVIDER" in
openai)
if grep -q "OPENAI_API_KEY" .env; then
test_passed "OpenAI API key configured"
else
test_failed "OpenAI provider selected but OPENAI_API_KEY not found in .env"
fi
;;
anthropic)
if grep -q "ANTHROPIC_API_KEY" .env; then
test_passed "Anthropic API key configured"
else
test_failed "Anthropic provider selected but ANTHROPIC_API_KEY not found in .env"
fi
;;
ollama|qwen)
test_passed "Local Ollama/Qwen provider configured"
if grep -q "CODEGRAPH_OLLAMA_URL" .env; then
OLLAMA_URL=$(grep "CODEGRAPH_OLLAMA_URL" .env | cut -d'=' -f2 | tr -d '"' | tr -d "'")
echo " Ollama URL: $OLLAMA_URL"
fi
;;
lmstudio)
test_passed "LM Studio provider configured"
if grep -q "CODEGRAPH_LMSTUDIO_URL" .env; then
LMSTUDIO_URL=$(grep "CODEGRAPH_LMSTUDIO_URL" .env | cut -d'=' -f2 | tr -d '"' | tr -d "'")
echo " LM Studio URL: $LMSTUDIO_URL"
fi
;;
*)
test_warning "LLM provider '$PROVIDER' may not be supported or configured correctly"
;;
esac
else
test_warning "LLM_PROVIDER not set in .env file"
echo " Set CODEGRAPH_LLM_PROVIDER=openai (or anthropic, ollama, etc.)"
fi
# Check model configuration
if grep -q "CODEGRAPH_MODEL" .env; then
MODEL=$(grep "CODEGRAPH_MODEL" .env | cut -d'=' -f2 | tr -d '"' | tr -d "'")
echo " Model: $MODEL"
else
test_warning "CODEGRAPH_MODEL not set in .env"
fi
else
test_failed ".env file not found in current directory"
echo " Create .env with LLM provider configuration"
fi
echo ""
# =============================================================================
# 6. Test MCP Server Build
# =============================================================================
echo -e "${YELLOW}[6/6] Checking CodeGraph MCP server binary...${NC}"
if command -v codegraph &> /dev/null; then
test_passed "CodeGraph MCP server binary is installed"
# Try to get version
VERSION_OUTPUT=$(codegraph --version 2>&1 || echo "unknown")
echo " Version: $VERSION_OUTPUT"
# Check if it's in PATH
BINARY_PATH=$(which codegraph)
echo " Location: $BINARY_PATH"
else
test_warning "CodeGraph binary not found in PATH"
echo " Build and install with: cargo install --path crates/codegraph-mcp"
fi
echo ""
# =============================================================================
# Summary
# =============================================================================
echo -e "${BLUE}═══════════════════════════════════════════════════${NC}"
echo -e "${BLUE} Verification Summary${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════${NC}"
echo ""
echo -e "${GREEN}Passed: $PASSED${NC}"
if [ $FAILED -gt 0 ]; then
echo -e "${RED}Failed: $FAILED${NC}"
fi
echo ""
if [ $FAILED -eq 0 ]; then
echo -e "${GREEN}✓ All critical checks passed!${NC}"
echo ""
echo "Next steps:"
echo "1. Apply schema (if not done): cd schema && ./apply-schema.sh"
echo "2. Index your codebase: codegraph index <path>"
echo "3. Start MCP server: codegraph start stdio"
echo ""
exit 0
else
echo -e "${RED}✗ Some checks failed. Please fix the issues above.${NC}"
echo ""
echo "Common fixes:"
echo "• Start SurrealDB: surreal start --bind 0.0.0.0:3004 --user root --pass root file://data/surreal.db"
echo "• Apply schema: cd schema && ./apply-schema.sh"
echo "• Configure LLM: Add CODEGRAPH_LLM_PROVIDER and API keys to .env"
echo "• Build MCP server: cargo build --release -p codegraph-mcp"
echo ""
exit 1
fi