From d9ba7201fade02bb8678f47eccb871302e0479de Mon Sep 17 00:00:00 2001 From: Chad Bentz <1760475+felickz@users.noreply.github.com> Date: Thu, 8 Oct 2026 16:24:01 -0400 Subject: [PATCH 1/2] Add CodeQL MCP server to Copilot setup steps and agent guidance Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7b18c848-a49d-4648-a3ee-80a6508d3e51 --- .github/agents/ql-tdd-agent.md | 4 +++- .github/workflows/copilot-setup-steps.yml | 18 ++++++++++++++++++ README.md | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/agents/ql-tdd-agent.md b/.github/agents/ql-tdd-agent.md index 608ae448..e2bea4be 100644 --- a/.github/agents/ql-tdd-agent.md +++ b/.github/agents/ql-tdd-agent.md @@ -12,9 +12,11 @@ My `ql-tdd-agent`: - Utilizes the `.github/prompts/*.prompt.md` prompt files as the primary guides for getting started with a given `ql` development task. - Utilizes the environment provided by the `.github/workflows/copilot-setup-steps.yml` actions workflow, which sets up the appropriate `codeql` CLI version for this project. - Utilizes the `.github/PULL_REQUEST_TEMPLATE/*.md` templates when creating Pull Requests for development changes. +- Prefers the `ql-mcp` MCP server tools (when connected) to inspect CodeQL's representation of code, compile queries, and run tests, and falls back to the `codeql` CLI for any operation the MCP tools do not expose. +- For false-negative (FN) and false-positive (FP) fixes, FIRST adds a regression test that reproduces the missed (or spurious) result, THEN fixes the query or library model, and explains the root cause in the Pull Request. NEVER simply accepts a missing detection as the new expected baseline. - Absolutely loves using the `codeql test extract` CLI command as a means of creating a test database (without running tests) against which the language-specific `PrintAST` query may be run. - Absolutely loves printing AST graph representations of test code as the primary means of understanding how CodeQL sees the syntax of some test code file. - Knows that the `codeql` CLI is pre-installed and ALWAYS uses the verbose help (i.e. `codeql -h -vv`) for any `codeql ` that the agent needs to run. - Keeps the `PROMPTS.md` documentation up-to-date -- especially its `mermaid` diagram -- as instructions, prompts, and (issue & PR) templates are added, deleted, or otherwise updated. -- ALWAYS uses the `codeql` CLI to perform and validate work related to `ql` code, test code, expected results, query logs, generated databases, etc. +- ALWAYS uses the `codeql` CLI (directly or through the `ql-mcp` MCP tools, which wrap it) to perform and validate work related to `ql` code, test code, expected results, query logs, generated databases, etc. - NEVER makes anything up. When in doubt, seeks to prove itself wrong with the `codeql` CLI. diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 514eda96..f0d1d0e0 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -37,3 +37,21 @@ jobs: - name: Copilot Setup - Install CodeQL workspace packs shell: bash run: ./scripts/install-codeql-packs.sh + + # The MCP server requires Node.js ^24.15.0 || >=26.0.0 (and npm >=11.6.2). + - name: Copilot Setup - Setup Node.js for CodeQL MCP server + uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 + with: + node-version: "26" + + - name: Copilot Setup - Install CodeQL MCP server and tool-pack dependencies + shell: bash + run: | + npm install --global codeql-development-mcp-server@2.27.1 + codeql-development-mcp-server-setup-packs + + - name: Copilot Setup - Verify CodeQL MCP server is available + shell: bash + run: | + codeql version + command -v codeql-development-mcp-server diff --git a/README.md b/README.md index e800d7fe..f6f17721 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,29 @@ This uses `codeql pack ls` to discover all packs in the workspace and runs `code > **Note:** The generated `codeql-pack.lock.yml` files should be committed to your repository to ensure reproducible dependency resolution across your team. +### Step 2a (Optional): Enable the CodeQL MCP Server for Copilot Coding Agent + +The 'copilot-setup-steps' workflow also installs the [CodeQL Development MCP Server](https://github.com/advanced-security/codeql-development-mcp-server) (`codeql-development-mcp-server`) into the agent environment. Installing it does not connect it: a repository administrator must register it once under **Settings → Copilot → Coding agent → MCP configuration**, preserving any existing entries: + +```json +{ + "mcpServers": { + "ql-mcp": { + "type": "local", + "command": "codeql-development-mcp-server", + "args": [], + "tools": ["*"] + } + } +} +``` + +See [GitHub's documentation on extending Copilot coding agent with MCP](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/configure-mcp-servers) for details. Notes: + +- The setup workflow must be merged to the **default branch** before Copilot uses it. +- Copilot Coding Agent supports MCP **tools** only (not MCP prompts or resources), so the prompts in this repository remain the primary guidance. +- Check the agent session logs to confirm `ql-mcp` connected and its tools were called. The `ql-tdd-agent` falls back to the `codeql` CLI if it is not connected. + ### Step 3: Create an Issue for the CodeQL query or data extension you want to develop 1. **Navigate to Issues** in your new repository From 389b9c5f7635d425844c4478b16f865ab5e70756 Mon Sep 17 00:00:00 2001 From: Chad Bentz <1760475+felickz@users.noreply.github.com> Date: Thu, 8 Oct 2026 16:28:08 -0400 Subject: [PATCH 2/2] Bump CodeQL CLI, standard library and bundle to 2.27.2 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7b18c848-a49d-4648-a3ee-80a6508d3e51 --- qlt.conf.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qlt.conf.json b/qlt.conf.json index 5a806a5b..ff06fe57 100644 --- a/qlt.conf.json +++ b/qlt.conf.json @@ -1,5 +1,5 @@ { - "CodeQLCLI": "2.25.2", - "CodeQLStandardLibrary": "codeql-cli/v2.25.2", - "CodeQLCLIBundle": "codeql-bundle-v2.25.2" + "CodeQLCLI": "2.27.2", + "CodeQLStandardLibrary": "codeql-cli/v2.27.2", + "CodeQLCLIBundle": "codeql-bundle-v2.27.2" }