88# 2. Monitoring mode (monitoring tools enabled) - tests session_* tools
99#
1010# Environment Variables:
11- # HTTP_HOST - Server host (default: localhost)
12- # HTTP_PORT - Server port (default: 3000)
11+ # MCP_MODE - MCP transport mode (default: stdio, also: http)
12+ # HTTP_HOST - Server host for HTTP mode (default: localhost)
13+ # HTTP_PORT - Server port for HTTP mode (default: 3000)
1314# TIMEOUT_SECONDS - Request timeout (default: 30)
1415# ENABLE_MONITORING_TOOLS - Force a specific mode instead of running both:
1516# "true" = only run with monitoring tools enabled
2021# ./run-integration-tests.sh # Run in BOTH modes (recommended)
2122# ENABLE_MONITORING_TOOLS=false ./run-integration-tests.sh # Only default mode
2223# ENABLE_MONITORING_TOOLS=true ./run-integration-tests.sh # Only monitoring mode
24+ # MCP_MODE=http ./run-integration-tests.sh # Run using HTTP transport
2325# ./run-integration-tests.sh --tools session_end # Filter to specific tools
2426
2527set -e
@@ -29,6 +31,7 @@ CLIENT_DIR="$(dirname "$SCRIPT_DIR")"
2931SERVER_DIR=" $( dirname " $CLIENT_DIR " ) /server"
3032
3133# Set default environment variables
34+ export MCP_MODE=" ${MCP_MODE:- stdio} "
3235export HTTP_HOST=" ${HTTP_HOST:- localhost} "
3336export HTTP_PORT=" ${HTTP_PORT:- 3000} "
3437export TIMEOUT_SECONDS=" ${TIMEOUT_SECONDS:- 30} "
@@ -65,7 +68,10 @@ for arg in "$@"; do
6568done
6669
6770echo " 🚀 Starting CodeQL MCP Integration Tests"
68- echo " Server URL: $URL_SCHEME ://$HTTP_HOST :$HTTP_PORT /mcp"
71+ echo " MCP Mode: $MCP_MODE "
72+ if [ " $MCP_MODE " = " http" ]; then
73+ echo " Server URL: $URL_SCHEME ://$HTTP_HOST :$HTTP_PORT /mcp"
74+ fi
6975
7076# Step 1: Build and bundle the server code
7177echo " 📦 Building CodeQL MCP server bundle..."
8187fi
8288
8389cd " $CLIENT_DIR "
84- export MCP_MODE=http
85- export MCP_SERVER_URL=" $URL_SCHEME ://$HTTP_HOST :$HTTP_PORT /mcp"
90+
91+ # For HTTP mode, set the server URL for the client
92+ if [ " $MCP_MODE " = " http" ]; then
93+ export MCP_SERVER_URL=" $URL_SCHEME ://$HTTP_HOST :$HTTP_PORT /mcp"
94+ fi
8695
8796# Function to run tests in a specific mode
8897run_tests_in_mode () {
8998 local mode_name=" $1 "
9099 local enable_monitoring=" $2 "
91-
100+ shift 2
101+
92102 echo " "
93103 echo " ═══════════════════════════════════════════════════════════════"
94104 echo " 🧪 Running integration tests: $mode_name "
95105 echo " ═══════════════════════════════════════════════════════════════"
96-
106+
97107 # Set the monitoring tools flag for this run
98108 export ENABLE_MONITORING_TOOLS=" $enable_monitoring "
99-
100- # Start MCP server with current settings
101- echo " 🚀 Starting MCP server (monitoring=$enable_monitoring )..."
102- " $SCRIPT_DIR /start-server.sh"
103-
104- # Wait for server startup
105- echo " ⏳ Waiting for server startup..."
106- " $SCRIPT_DIR /wait-for-server.sh"
107-
109+
110+ if [ " $MCP_MODE " = " http" ]; then
111+ # HTTP mode: start server in background, run tests, stop server
112+ echo " 🚀 Starting MCP server (monitoring=$enable_monitoring )..."
113+ " $SCRIPT_DIR /start-server.sh"
114+
115+ # Wait for server startup
116+ echo " ⏳ Waiting for server startup..."
117+ " $SCRIPT_DIR /wait-for-server.sh"
118+ else
119+ # stdio mode: client spawns server directly via StdioClientTransport
120+ echo " 📡 Using stdio transport (client spawns server directly)"
121+ fi
122+
108123 # Run the integration tests (skip pack installation since we already did it)
109124 echo " 🧪 Running tests..."
110125 node src/ql-mcp-client.js integration-tests --no-install-packs " $@ "
111-
112- # Stop the server before next mode
113- echo " 🛑 Stopping server..."
114- " $SCRIPT_DIR /stop-server.sh"
126+
127+ if [ " $MCP_MODE " = " http" ]; then
128+ # Stop the server before next mode
129+ echo " 🛑 Stopping server..."
130+ " $SCRIPT_DIR /stop-server.sh"
131+ fi
115132}
116133
117134# Trap to ensure cleanup happens even if script fails
118135cleanup () {
119136 echo " 🧹 Cleaning up..."
120- " $SCRIPT_DIR /stop-server.sh" 2> /dev/null || true
137+ if [ " $MCP_MODE " = " http" ]; then
138+ " $SCRIPT_DIR /stop-server.sh" 2> /dev/null || true
139+ fi
121140}
122141trap cleanup EXIT
123142
0 commit comments