Skip to content

Commit 3a48ec7

Browse files
committed
feat: add HTTP server testing scripts for structured outputs
Created helper scripts for testing agentic tools via HTTP transport: start_http_server.sh: - Starts CodeGraph HTTP server with all features - Shows configuration (LLM, SurrealDB, context window) - Auto-builds if binary missing - Default: http://127.0.0.1:3000 test_http_agentic.sh: - Tests agentic_code_search via HTTP - Parses and displays structured output - Extracts components with file paths - Shows patterns identified - Saves full response to test_http_search_response.json Usage: Terminal 1: ./start_http_server.sh Terminal 2: ./test_http_agentic.sh
1 parent a228392 commit 3a48ec7

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed

start_http_server.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
# Start CodeGraph HTTP server with all features
3+
4+
set -e
5+
6+
PORT="${CODEGRAPH_HTTP_PORT:-3000}"
7+
HOST="${CODEGRAPH_HTTP_HOST:-127.0.0.1}"
8+
9+
echo "🚀 Starting CodeGraph HTTP Server"
10+
echo "=================================================="
11+
echo "Host: $HOST"
12+
echo "Port: $PORT"
13+
echo ""
14+
echo "Features:"
15+
echo " ✅ AutoAgents framework (experimental)"
16+
echo " ✅ Structured outputs with JSON schemas"
17+
echo " ✅ 7 agentic tools with file path enforcement"
18+
echo " ✅ SSE streaming support"
19+
echo ""
20+
echo "Configuration:"
21+
echo " LLM Provider: ${CODEGRAPH_LLM_PROVIDER:-ollama}"
22+
echo " LLM Model: ${CODEGRAPH_MODEL:-qwen2.5-coder:14b}"
23+
echo " Context Window: ${CODEGRAPH_CONTEXT_WINDOW:-32768}"
24+
echo ""
25+
echo " SurrealDB URL: ${SURREALDB_URL:-ws://localhost:3004}"
26+
echo " SurrealDB Namespace: ${SURREALDB_NAMESPACE:-codegraph}"
27+
echo " SurrealDB Database: ${SURREALDB_DATABASE:-main}"
28+
echo ""
29+
echo "Press Ctrl+C to stop server"
30+
echo "=================================================="
31+
echo ""
32+
33+
# Check if binary exists
34+
if [ ! -f "./target/release/codegraph" ]; then
35+
echo "❌ Release binary not found. Building..."
36+
echo ""
37+
cargo build --release \
38+
-p codegraph-mcp \
39+
--bin codegraph \
40+
--features "ai-enhanced,autoagents-experimental,embeddings-ollama,server-http,faiss"
41+
echo ""
42+
echo "✅ Build complete"
43+
echo ""
44+
fi
45+
46+
# Start server
47+
./target/release/codegraph start http --host "$HOST" --port "$PORT"

test_http_agentic.sh

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/bin/bash
2+
# Test agentic tools via HTTP transport with structured outputs
3+
4+
set -e
5+
6+
PORT="${CODEGRAPH_HTTP_PORT:-3000}"
7+
HOST="${CODEGRAPH_HTTP_HOST:-127.0.0.1}"
8+
BASE_URL="http://${HOST}:${PORT}"
9+
10+
echo "🌐 Testing CodeGraph HTTP Server with Structured Outputs"
11+
echo "=================================================="
12+
echo "Server: $BASE_URL"
13+
echo ""
14+
15+
# Check if server is running
16+
echo "1. Health Check..."
17+
if curl -sf "${BASE_URL}/health" > /dev/null; then
18+
echo "✅ Server is running"
19+
else
20+
echo "❌ Server not running. Start with:"
21+
echo " ./target/release/codegraph start http --port $PORT"
22+
exit 1
23+
fi
24+
25+
echo ""
26+
echo "2. Initialize MCP connection..."
27+
INIT_RESPONSE=$(curl -s -X POST "${BASE_URL}/mcp" \
28+
-H "Content-Type: application/json" \
29+
-d '{
30+
"jsonrpc": "2.0",
31+
"id": 1,
32+
"method": "initialize",
33+
"params": {
34+
"protocolVersion": "2025-06-18",
35+
"capabilities": {},
36+
"clientInfo": {"name": "http-tester", "version": "1.0"}
37+
}
38+
}')
39+
40+
echo "$INIT_RESPONSE" | jq '.' 2>/dev/null || echo "$INIT_RESPONSE"
41+
42+
if echo "$INIT_RESPONSE" | grep -q '"result"'; then
43+
echo "✅ MCP initialized"
44+
else
45+
echo "❌ Initialize failed"
46+
exit 1
47+
fi
48+
49+
echo ""
50+
echo "3. Test agentic_code_search with structured output..."
51+
echo " Query: How is configuration loaded in this codebase?"
52+
echo " Expected: structured_output with components[] containing file paths"
53+
echo ""
54+
55+
SEARCH_RESPONSE=$(curl -s -X POST "${BASE_URL}/mcp" \
56+
-H "Content-Type: application/json" \
57+
-d '{
58+
"jsonrpc": "2.0",
59+
"id": 201,
60+
"method": "tools/call",
61+
"params": {
62+
"name": "agentic_code_search",
63+
"arguments": {
64+
"query": "How is configuration loaded in this codebase? Find all config loading mechanisms."
65+
}
66+
}
67+
}')
68+
69+
# Save full response
70+
echo "$SEARCH_RESPONSE" > test_http_search_response.json
71+
echo "📁 Full response saved to: test_http_search_response.json"
72+
73+
# Extract and display structured output
74+
echo ""
75+
echo "Response Analysis:"
76+
echo "=================================================="
77+
78+
if echo "$SEARCH_RESPONSE" | jq -e '.result[0].content[0].text' > /dev/null 2>&1; then
79+
RESULT_TEXT=$(echo "$SEARCH_RESPONSE" | jq -r '.result[0].content[0].text')
80+
81+
# Parse the result text as JSON
82+
echo "$RESULT_TEXT" > /tmp/result_parsed.json
83+
84+
if echo "$RESULT_TEXT" | jq -e '.structured_output' > /dev/null 2>&1; then
85+
echo "✅ Structured output present!"
86+
echo ""
87+
echo "Components found:"
88+
echo "$RESULT_TEXT" | jq -r '.structured_output.components[] | " - \(.name) in \(.file_path):\(.line_number // 0)"' 2>/dev/null | head -5
89+
90+
echo ""
91+
echo "Patterns identified:"
92+
echo "$RESULT_TEXT" | jq -r '.structured_output.patterns[]' 2>/dev/null | head -3
93+
94+
echo ""
95+
COMP_COUNT=$(echo "$RESULT_TEXT" | jq '.structured_output.components | length' 2>/dev/null)
96+
echo "Total components with file paths: $COMP_COUNT"
97+
echo "Steps taken: $(echo "$RESULT_TEXT" | jq -r '.steps_taken')"
98+
else
99+
echo "⚠️ No structured_output field found"
100+
echo "Response keys:"
101+
echo "$RESULT_TEXT" | jq 'keys' 2>/dev/null || echo "$RESULT_TEXT" | head -20
102+
fi
103+
else
104+
echo "❌ Failed to extract result from response"
105+
echo "$SEARCH_RESPONSE" | jq '.' 2>/dev/null || echo "$SEARCH_RESPONSE"
106+
fi
107+
108+
echo ""
109+
echo "=================================================="
110+
echo "📋 Full results in: test_http_search_response.json"
111+
echo "💡 Inspect with: jq '.result[0].content[0].text | fromjson' test_http_search_response.json"

0 commit comments

Comments
 (0)