Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/client-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ permissions:

jobs:
integration-tests:
name: Integration Tests (${{ matrix.os }})
name: Integration Tests (${{ matrix.os }}, ${{ matrix.mcp-mode }})
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
mcp-mode: [http, stdio]
os: [ubuntu-latest, windows-latest]

env:
HTTP_HOST: 'localhost'
HTTP_PORT: '3000'
MCP_MODE: ${{ matrix.mcp-mode }}
TIMEOUT_SECONDS: '30'
URL_SCHEME: 'http'

Expand Down Expand Up @@ -110,7 +112,7 @@ jobs:
run: npm run test:integration --workspace=client

- name: MCP Integration Tests - Stop the background MCP server process
if: always()
if: always() && matrix.mcp-mode == 'http'
shell: bash
run: |
if [ -f server.pid ]; then
Expand Down Expand Up @@ -141,8 +143,8 @@ jobs:
- name: MCP Integration Tests - Summary
shell: bash
run: |
echo "## Integration Tests Summary (${{ matrix.os }})" >> $GITHUB_STEP_SUMMARY
echo "✅ MCP server integration tests passed on ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY
echo "## Integration Tests Summary (${{ matrix.os }}, ${{ matrix.mcp-mode }})" >> $GITHUB_STEP_SUMMARY
echo "✅ MCP server integration tests passed on ${{ matrix.os }} with ${{ matrix.mcp-mode }} transport" >> $GITHUB_STEP_SUMMARY

codeql-path-tests:
name: CODEQL_PATH Tests (${{ matrix.os }})
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ codeql-development-mcp-server.code-workspace
# Prevent accidentally committing integration test output files in root directory
# These should only be in client/integration-tests/primitives/tools/*/after/ directories
/evaluator-log.json
/client/query-results/
/client/query-results.bqrs
/client/query-results.sarif
/query-results/
/query-results.bqrs
/query-results.sarif
Expand Down
4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@
"test:coverage": "echo 'NOOP client test:coverage'",
"test:integration": "scripts/run-integration-tests.sh --no-install-packs",
"test:integration:default": "ENABLE_MONITORING_TOOLS=false scripts/run-integration-tests.sh --no-install-packs",
"test:integration:http": "MCP_MODE=http scripts/run-integration-tests.sh --no-install-packs",
"test:integration:install-packs": "scripts/run-integration-tests.sh",
"test:integration:monitoring": "ENABLE_MONITORING_TOOLS=true scripts/run-integration-tests.sh",
"test:integration:monitoring": "ENABLE_MONITORING_TOOLS=true scripts/run-integration-tests.sh --no-install-packs",
"test:integration:stdio": "MCP_MODE=stdio scripts/run-integration-tests.sh --no-install-packs",
"tidy": "npm run lint && npm run format"
}
}
61 changes: 40 additions & 21 deletions client/scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
# 2. Monitoring mode (monitoring tools enabled) - tests session_* tools
#
# Environment Variables:
# HTTP_HOST - Server host (default: localhost)
# HTTP_PORT - Server port (default: 3000)
# MCP_MODE - MCP transport mode (default: stdio, also: http)
# HTTP_HOST - Server host for HTTP mode (default: localhost)
# HTTP_PORT - Server port for HTTP mode (default: 3000)
# TIMEOUT_SECONDS - Request timeout (default: 30)
# ENABLE_MONITORING_TOOLS - Force a specific mode instead of running both:
# "true" = only run with monitoring tools enabled
Expand All @@ -20,6 +21,7 @@
# ./run-integration-tests.sh # Run in BOTH modes (recommended)
# ENABLE_MONITORING_TOOLS=false ./run-integration-tests.sh # Only default mode
# ENABLE_MONITORING_TOOLS=true ./run-integration-tests.sh # Only monitoring mode
# MCP_MODE=http ./run-integration-tests.sh # Run using HTTP transport
# ./run-integration-tests.sh --tools session_end # Filter to specific tools

set -e
Expand All @@ -29,6 +31,7 @@ CLIENT_DIR="$(dirname "$SCRIPT_DIR")"
SERVER_DIR="$(dirname "$CLIENT_DIR")/server"

# Set default environment variables
export MCP_MODE="${MCP_MODE:-stdio}"
export HTTP_HOST="${HTTP_HOST:-localhost}"
export HTTP_PORT="${HTTP_PORT:-3000}"
export TIMEOUT_SECONDS="${TIMEOUT_SECONDS:-30}"
Expand Down Expand Up @@ -65,7 +68,10 @@ for arg in "$@"; do
done

echo "🚀 Starting CodeQL MCP Integration Tests"
echo "Server URL: $URL_SCHEME://$HTTP_HOST:$HTTP_PORT/mcp"
echo "MCP Mode: $MCP_MODE"
if [ "$MCP_MODE" = "http" ]; then
echo "Server URL: $URL_SCHEME://$HTTP_HOST:$HTTP_PORT/mcp"
fi

# Step 1: Build and bundle the server code
echo "📦 Building CodeQL MCP server bundle..."
Expand All @@ -81,43 +87,56 @@ else
fi

cd "$CLIENT_DIR"
export MCP_MODE=http
export MCP_SERVER_URL="$URL_SCHEME://$HTTP_HOST:$HTTP_PORT/mcp"

# For HTTP mode, set the server URL for the client
if [ "$MCP_MODE" = "http" ]; then
export MCP_SERVER_URL="$URL_SCHEME://$HTTP_HOST:$HTTP_PORT/mcp"
fi

# Function to run tests in a specific mode
run_tests_in_mode() {
local mode_name="$1"
local enable_monitoring="$2"

shift 2

echo ""
echo "═══════════════════════════════════════════════════════════════"
echo "🧪 Running integration tests: $mode_name"
echo "═══════════════════════════════════════════════════════════════"

# Set the monitoring tools flag for this run
export ENABLE_MONITORING_TOOLS="$enable_monitoring"

# Start MCP server with current settings
echo "🚀 Starting MCP server (monitoring=$enable_monitoring)..."
"$SCRIPT_DIR/start-server.sh"

# Wait for server startup
echo "⏳ Waiting for server startup..."
"$SCRIPT_DIR/wait-for-server.sh"


if [ "$MCP_MODE" = "http" ]; then
# HTTP mode: start server in background, run tests, stop server
echo "🚀 Starting MCP server (monitoring=$enable_monitoring)..."
"$SCRIPT_DIR/start-server.sh"

# Wait for server startup
echo "⏳ Waiting for server startup..."
"$SCRIPT_DIR/wait-for-server.sh"
else
# stdio mode: client spawns server directly via StdioClientTransport
echo "📡 Using stdio transport (client spawns server directly)"
fi

# Run the integration tests (skip pack installation since we already did it)
echo "🧪 Running tests..."
node src/ql-mcp-client.js integration-tests --no-install-packs "$@"

# Stop the server before next mode
echo "🛑 Stopping server..."
"$SCRIPT_DIR/stop-server.sh"

if [ "$MCP_MODE" = "http" ]; then
# Stop the server before next mode
echo "🛑 Stopping server..."
"$SCRIPT_DIR/stop-server.sh"
fi
}

# Trap to ensure cleanup happens even if script fails
cleanup() {
echo "🧹 Cleaning up..."
"$SCRIPT_DIR/stop-server.sh" 2>/dev/null || true
if [ "$MCP_MODE" = "http" ]; then
"$SCRIPT_DIR/stop-server.sh" 2>/dev/null || true
fi
}
trap cleanup EXIT

Expand Down
6 changes: 6 additions & 0 deletions client/src/lib/cli-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ OPTIONS:
Example: --timeout 600

--help Display help information

ENVIRONMENT VARIABLES:
MCP_MODE MCP transport mode: stdio (default) or http
MCP_SERVER_PATH Path to the MCP server JS entry point (stdio mode only)
MCP_SERVER_URL MCP server URL (http mode only, default: http://localhost:3000/mcp)
ENABLE_MONITORING_TOOLS Enable session_* monitoring tools (default: false)
`;
}

Expand Down
Loading