Skip to content

Comments

Add stdio transport support to client integration test runner#77

Merged
data-douser merged 6 commits intomainfrom
copilot/update-client-integration-test-runner
Feb 23, 2026
Merged

Add stdio transport support to client integration test runner#77
data-douser merged 6 commits intomainfrom
copilot/update-client-integration-test-runner

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

Integration Testing Improvement PR: MCP Server Primitives

Related Issue: #76

Scope Guard: This PR extends beyond client/integration-tests/** by necessity — the integration test runner infrastructure, CI workflow, and documentation all required updates to support dual-transport testing. No server code changes.

Summary

Client integration tests only exercised the HTTP transport, but stdio is the default (and most common) mode for end users. This PR adds StdioClientTransport support to the MCP client so integration tests can run against either transport, defaults everything to stdio, and updates CI to matrix-test both modes. The MCP_MODE env var is normalized to lowercase and only an explicit value of "http" triggers HTTP transport — all other values (including typos or case variations) default to stdio, consistent across both the JS client and the bash runner.

Primitive Metadata

  • Primitive name(s): All MCP tools (transport-layer change, not tool-specific)
  • Type(s): Combination
  • Related resources or prompts (if any): N/A

Test Additions / Modifications

No new test cases — the existing integration tests now run over both transports.

  • client/src/ql-mcp-client.js: connect() branches on MCP_MODE env var (normalized to lowercase, stdio default). Only MCP_MODE=http triggers HTTP transport; all other values use StdioClientTransport. Server path configurable via MCP_SERVER_PATH.
  • client/scripts/run-integration-tests.sh: Skips manual server start/stop/wait in stdio mode (client manages lifecycle). MCP_MODE defaults to stdio. Uses shift 2 in run_tests_in_mode() so internal positional args (mode_name, enable_monitoring) are not forwarded to the node CLI.
  • client/package.json: Added test:integration:http and test:integration:stdio scripts.
  • client/src/lib/cli-parser.js: Documented new env vars (MCP_MODE, MCP_SERVER_PATH, MCP_SERVER_URL, ENABLE_MONITORING_TOOLS) in help text.
  • .github/workflows/client-integration-tests.yml: Added mcp-mode: [http, stdio] matrix dimension. Server cleanup conditional on HTTP mode.
  • docs/testing.md: Documents stdio as default transport for Layer 2a.
  • docs/getting-started.md, docs/public.md: Recommend VSIX installation as primary method.

Before vs After File States

N/A — no fixture file changes. The transport layer is transparent to test assertions.

Assertions Added

  • Tool result validation (success, error handling)
  • Other: Existing test assertions now validated over both stdio and HTTP transports via CI matrix

Edge & Negative Cases

  • stdio mode: StdioClientTransport spawns server as child process — if server crashes, transport surfaces the error naturally via MCP SDK
  • HTTP cleanup step in CI gated on matrix.mcp-mode == 'http' to avoid no-op failures in stdio runs
  • MCP_MODE is case-insensitive: STDIO, Stdio, stdio all resolve to stdio transport; only http (any case) triggers HTTP — consistent between the JS client and bash runner

Non-Goals / Deferred Follow-ups

  • No changes to individual test fixtures or assertions
  • Monitoring-mode tests (session_* tools) unchanged — they work identically over both transports

Local Verification

# Full lint + format + server unit tests
npm run tidy:check && npm run test:server  #

# CodeQL security scan
# 0 alerts

CI will validate actual integration test execution over both transports via the updated matrix.

Checklist

  • Scope limited to client/integration-tests/**
  • All new tests pass locally
  • Does not introduce unrelated refactors
  • Documentation/comments updated where helpful
  • Re-ran tests to confirm deterministic results
  • Added negative test (or documented why not applicable)
  • Linked accepted issue in description
  • Followed directory structure (primitives/tools/<tool>/<test>/before|after)
  • Each file in before has matching file in after
  • No binary or non-diffable files added
  • Tests focus on a single primitive concern
  • Ran npm run lint:fix and npm run build-and-test successfully
  • Checked for accidental changes outside allowed path

Screenshots / Logs (Optional)

N/A — transport-layer change; no visible output differences.

Additional Notes

The scope guard is intentionally exceeded: this is a test infrastructure change (runner + CI + docs), not a test case change. The StdioClientTransport import comes from the existing @modelcontextprotocol/sdk dependency — no new packages added.


Maintainers: Reject or request split if scope exceeds integration test boundaries.

Original prompt

This section details on the original issue you should resolve

<issue_title>Update client integration test runner to validate MCP server functionality in stdio mode</issue_title>
<issue_description>## Problem to Resolve

Client integration tests currently only test the HTTP run mode of the codeql-development-mcp-server, even though it supports both http and stdio MCP server run modes.

Expected Outcomes

  • Client integration tests need to be able to test either mode of the MCP server, especially since the stdio run mode is the default mod that most users will use for the MCP server.
  • Actions workflows for client integration tests must test both server run modes.
  • The default "npm run build-and-test" must test against just stdio mode by default.
  • The client integration test runner must be updated as needed to support these requirements.
  • The docs/testing.md documentation must accurately reflect the requirements for testing the stdio mode as the primary/default run mode for codeql-development-mcp-server.
  • The docs/public.md and docs/getting-started.md documentation files must recommend / prefer the vscode-codeql-development-mcp-server installation method (from release VSIX archive bundle).</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: ql-mcp-tool-tester
An agent for testing and validating tools for the latest QL Development MCP Server.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 23, 2026 16:20
- Update client to support both stdio and http transport modes (MCP_MODE env var, default: stdio)
- In stdio mode, client spawns server via StdioClientTransport from MCP SDK
- Update run-integration-tests.sh to skip manual server start/stop in stdio mode
- Add test:integration:http and test:integration:stdio scripts to client/package.json
- Update CI workflow to test both transport modes via matrix strategy
- Update docs/testing.md to document stdio as default transport
- Update docs/getting-started.md and docs/public.md to recommend VSIX installation

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Add MCP_SERVER_PATH env var support for configuring the server binary path
in stdio mode. Update CLI help text to document new environment variables.

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copilot AI changed the title [WIP] Update client integration test runner for MCP server functionality Add stdio transport support to client integration test runner Feb 23, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@data-douser data-douser added the enhancement New feature or request label Feb 23, 2026
@data-douser data-douser changed the title Add stdio transport support to client integration test runner Add stdio transport support to client integration test runner Feb 23, 2026
Bug 1 — CWD mismatch in stdio mode (both platforms):
StdioClientTransport inherited the client/ working directory, so
relative paths passed to CodeQL CLI (e.g. server/ql/javascript/...)
resolved to client/server/ql/... which does not exist. Add cwd: repoRoot
to the transport options to match the HTTP-mode behavior where
start-server.sh explicitly cd's to the repo root.

Bug 2 — False success on Windows in stdio mode:
StdioClientTransport.close() could cause an abrupt process exit on
Windows before printTestSummary() and process.exit(exitCode) were
reached, so the shell script saw exit code 0 and reported success
despite test failures. Move summary printing and process.exitCode
assignment above the disconnect() call in all four run methods so
results are always reported even if disconnect triggers an early exit.
@data-douser data-douser marked this pull request as ready for review February 23, 2026 19:12
@data-douser data-douser requested review from a team, data-douser and enyil as code owners February 23, 2026 19:12
Copilot AI review requested due to automatic review settings February 23, 2026 19:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds dual-transport support to the client-side integration test infrastructure so the existing MCP tool integration tests can run against the server over either stdio (default) or HTTP, and updates CI/docs accordingly (no server tool changes).

Changes:

  • Update client/src/ql-mcp-client.js to select StdioClientTransport vs StreamableHTTPClientTransport based on MCP_MODE (defaulting to stdio) and support MCP_SERVER_PATH for stdio runs.
  • Update the integration test runner script + client package scripts to support explicit stdio/http modes, with lifecycle management differences between transports.
  • Update GitHub Actions workflow and documentation to reflect stdio as the primary/default transport and recommend VSIX installation.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
client/src/ql-mcp-client.js Adds stdio transport support and mode-aware logging/exit flow for integration runs.
client/scripts/run-integration-tests.sh Adds MCP_MODE defaulting to stdio and avoids HTTP server lifecycle steps when running stdio.
client/package.json Adds explicit test:integration:http / test:integration:stdio scripts and aligns monitoring script flags.
client/src/lib/cli-parser.js Documents new env vars (MCP_MODE, MCP_SERVER_PATH, etc.) in CLI help output.
.github/workflows/client-integration-tests.yml Adds a mcp-mode: [http, stdio] matrix and gates HTTP cleanup steps.
docs/testing.md Documents dual transport modes and notes stdio as the default transport for integration tests.
docs/public.md Recommends VSIX/extension installation as the primary path; keeps npm as an alternative.
docs/getting-started.md Clarifies VSIX install steps and reinforces extension-first onboarding.
.gitignore Ignores additional client query output artifacts to prevent accidental commits.

@data-douser
Copy link
Collaborator

@copilot apply changes based on the comments in this thread

…warding

- Normalize MCP_MODE to lowercase in client constructor so that
  MCP_MODE=STDIO works the same as MCP_MODE=stdio
- Select stdio transport by default; only use HTTP when MCP_MODE === "http"
  (previously any non-"stdio" value fell through to HTTP)
- Add shift 2 in run_tests_in_mode() so mode_name and enable_monitoring
  positional args are not forwarded to node as extra CLI arguments

Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@copilot apply changes based on the comments in this thread

Both review comments addressed in 04661fb:

  • run_tests_in_mode() now uses shift 2 so internal args aren't forwarded to node
  • MCP_MODE normalized to lowercase; stdio is the default transport (only "http" triggers HTTP)

@data-douser data-douser enabled auto-merge (squash) February 23, 2026 20:59
@data-douser data-douser disabled auto-merge February 23, 2026 23:28
@data-douser data-douser merged commit 4baf6af into main Feb 23, 2026
15 checks passed
@data-douser data-douser deleted the copilot/update-client-integration-test-runner branch February 23, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update client integration test runner to validate MCP server functionality in stdio mode

2 participants