From be748f5d26a4198bf7ad4046092912fedb446141 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Jul 2026 08:31:53 +0000 Subject: [PATCH 1/6] Initial plan From 01dfc99ed4cc3b8a9f185f5340a892db6a95da4c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Jul 2026 08:47:38 +0000 Subject: [PATCH 2/6] Bound list_code_scanning_alerts prompt usage Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/aw/github-mcp-server.md | 3 +- .github/skills/github-mcp-server/SKILL.md | 2 ++ docs/src/content/docs/guides/mcps.md | 2 ++ pkg/cli/code_scanning_prompt_bounds_test.go | 37 +++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 pkg/cli/code_scanning_prompt_bounds_test.go diff --git a/.github/aw/github-mcp-server.md b/.github/aw/github-mcp-server.md index e0a05420b8c..94d054d2245 100644 --- a/.github/aw/github-mcp-server.md +++ b/.github/aw/github-mcp-server.md @@ -204,6 +204,8 @@ The following toolsets are recommended as defaults for typical agentic workflows | `get_code_scanning_alert` | Get details of a specific code scanning alert | `owner`, `repo`, `alert_number` | | `list_code_scanning_alerts` | List code scanning alerts for a repository | `owner`, `repo`, `state`, `severity` | +When calling `list_code_scanning_alerts` in workflow prompts/templates, always bound requests with `state: open` and `severity: critical,high`. + --- ### dependabot @@ -368,4 +370,3 @@ Most toolsets work with the default `GITHUB_TOKEN` in GitHub Actions. Exceptions - `projects` — Requires a PAT with `project` scope - `security_advisories` (write) — Requires `security-events: write` permission - `actions` (write for `actions_run_trigger`) — Requires `actions: write` permission - diff --git a/.github/skills/github-mcp-server/SKILL.md b/.github/skills/github-mcp-server/SKILL.md index c436d331ed8..33672d831cf 100644 --- a/.github/skills/github-mcp-server/SKILL.md +++ b/.github/skills/github-mcp-server/SKILL.md @@ -173,6 +173,8 @@ This section maps individual tools to their respective toolsets to help with mig - `get_code_scanning_alert` - Get details of a specific alert - `create_code_scanning_alert` - Create a code scanning alert +When invoking `list_code_scanning_alerts` from workflow prompts/templates, always include `state: open` and `severity: critical,high`. + ### Discussions Toolset - `list_discussions` - List discussions in a repository - `create_discussion` - Create a new discussion diff --git a/docs/src/content/docs/guides/mcps.md b/docs/src/content/docs/guides/mcps.md index fa4fee903a5..81e2117ce8f 100644 --- a/docs/src/content/docs/guides/mcps.md +++ b/docs/src/content/docs/guides/mcps.md @@ -61,6 +61,8 @@ The GitHub MCP server is built into agentic workflows and provides comprehensive | `code_security` | Security alerts | `list_code_scanning_alerts` | | `users` | User profiles | `get_me` ⚠️, `get_user`, `list_users` | +When calling `list_code_scanning_alerts` from workflow prompts, always bound the request with `state: open` and `severity: critical,high`. + The `default` toolset includes: `context`, `repos`, `issues`, `pull_requests`. When used in workflows, `[default]` expands to action-friendly toolsets that work with GitHub Actions tokens. Note: The `users` toolset is not included by default as GitHub Actions tokens do not support user operations. > [!WARNING] diff --git a/pkg/cli/code_scanning_prompt_bounds_test.go b/pkg/cli/code_scanning_prompt_bounds_test.go new file mode 100644 index 00000000000..8a48674994b --- /dev/null +++ b/pkg/cli/code_scanning_prompt_bounds_test.go @@ -0,0 +1,37 @@ +//go:build !integration + +package cli + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +func TestListCodeScanningAlertsPromptBounds(t *testing.T) { + paths := []string{ + filepath.Join("..", "..", ".github", "workflows", "github-mcp-structural-analysis.md"), + filepath.Join("..", "..", ".github", "aw", "github-mcp-server.md"), + filepath.Join("..", "..", ".github", "skills", "github-mcp-server", "SKILL.md"), + } + + for _, path := range paths { + t.Run(path, func(t *testing.T) { + content, err := os.ReadFile(path) + if err != nil { + t.Fatalf("failed to read %s: %v", path, err) + } + text := string(content) + if !strings.Contains(text, "list_code_scanning_alerts") { + t.Fatalf("%s must reference list_code_scanning_alerts", path) + } + if !strings.Contains(text, "state: open") { + t.Fatalf("%s must include state: open guard", path) + } + if !strings.Contains(text, "severity: critical,high") { + t.Fatalf("%s must include severity: critical,high guard", path) + } + }) + } +} From 98e1f6d95c8be540d6d31d5f0e5eb9026e4a0257 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Jul 2026 08:51:24 +0000 Subject: [PATCH 3/6] Harden list_code_scanning_alerts bounds regression test Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/code_scanning_prompt_bounds_test.go | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkg/cli/code_scanning_prompt_bounds_test.go b/pkg/cli/code_scanning_prompt_bounds_test.go index 8a48674994b..8930c5776cc 100644 --- a/pkg/cli/code_scanning_prompt_bounds_test.go +++ b/pkg/cli/code_scanning_prompt_bounds_test.go @@ -24,13 +24,25 @@ func TestListCodeScanningAlertsPromptBounds(t *testing.T) { } text := string(content) if !strings.Contains(text, "list_code_scanning_alerts") { - t.Fatalf("%s must reference list_code_scanning_alerts", path) + t.Skipf("%s does not reference list_code_scanning_alerts", path) } - if !strings.Contains(text, "state: open") { - t.Fatalf("%s must include state: open guard", path) + + lines := strings.Split(text, "\n") + hasBoundedReference := false + for i, line := range lines { + if !strings.Contains(line, "list_code_scanning_alerts") { + continue + } + start := max(0, i-8) + end := min(len(lines), i+9) + window := strings.Join(lines[start:end], "\n") + if strings.Contains(window, "state: open") && strings.Contains(window, "severity: critical,high") { + hasBoundedReference = true + break + } } - if !strings.Contains(text, "severity: critical,high") { - t.Fatalf("%s must include severity: critical,high guard", path) + if !hasBoundedReference { + t.Fatalf("%s must include state: open and severity: critical,high near list_code_scanning_alerts", path) } }) } From 51751a4551f36fca359a2aa366f7d464b53177ce Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Jul 2026 08:54:03 +0000 Subject: [PATCH 4/6] Document and enforce bounded code-scanning alert queries Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/code_scanning_prompt_bounds_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/cli/code_scanning_prompt_bounds_test.go b/pkg/cli/code_scanning_prompt_bounds_test.go index 8930c5776cc..c55e5cab904 100644 --- a/pkg/cli/code_scanning_prompt_bounds_test.go +++ b/pkg/cli/code_scanning_prompt_bounds_test.go @@ -9,6 +9,8 @@ import ( "testing" ) +const codeScanningAlertGuardLineWindow = 8 + func TestListCodeScanningAlertsPromptBounds(t *testing.T) { paths := []string{ filepath.Join("..", "..", ".github", "workflows", "github-mcp-structural-analysis.md"), @@ -33,8 +35,8 @@ func TestListCodeScanningAlertsPromptBounds(t *testing.T) { if !strings.Contains(line, "list_code_scanning_alerts") { continue } - start := max(0, i-8) - end := min(len(lines), i+9) + start := max(0, i-codeScanningAlertGuardLineWindow) + end := min(len(lines), i+codeScanningAlertGuardLineWindow+1) window := strings.Join(lines[start:end], "\n") if strings.Contains(window, "state: open") && strings.Contains(window, "severity: critical,high") { hasBoundedReference = true From 31eed7e09e76734c63cad5727714f2f16e364d90 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Jul 2026 11:19:39 +0000 Subject: [PATCH 5/6] Remove code_scanning_prompt_bounds_test.go Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/code_scanning_prompt_bounds_test.go | 51 --------------------- 1 file changed, 51 deletions(-) delete mode 100644 pkg/cli/code_scanning_prompt_bounds_test.go diff --git a/pkg/cli/code_scanning_prompt_bounds_test.go b/pkg/cli/code_scanning_prompt_bounds_test.go deleted file mode 100644 index c55e5cab904..00000000000 --- a/pkg/cli/code_scanning_prompt_bounds_test.go +++ /dev/null @@ -1,51 +0,0 @@ -//go:build !integration - -package cli - -import ( - "os" - "path/filepath" - "strings" - "testing" -) - -const codeScanningAlertGuardLineWindow = 8 - -func TestListCodeScanningAlertsPromptBounds(t *testing.T) { - paths := []string{ - filepath.Join("..", "..", ".github", "workflows", "github-mcp-structural-analysis.md"), - filepath.Join("..", "..", ".github", "aw", "github-mcp-server.md"), - filepath.Join("..", "..", ".github", "skills", "github-mcp-server", "SKILL.md"), - } - - for _, path := range paths { - t.Run(path, func(t *testing.T) { - content, err := os.ReadFile(path) - if err != nil { - t.Fatalf("failed to read %s: %v", path, err) - } - text := string(content) - if !strings.Contains(text, "list_code_scanning_alerts") { - t.Skipf("%s does not reference list_code_scanning_alerts", path) - } - - lines := strings.Split(text, "\n") - hasBoundedReference := false - for i, line := range lines { - if !strings.Contains(line, "list_code_scanning_alerts") { - continue - } - start := max(0, i-codeScanningAlertGuardLineWindow) - end := min(len(lines), i+codeScanningAlertGuardLineWindow+1) - window := strings.Join(lines[start:end], "\n") - if strings.Contains(window, "state: open") && strings.Contains(window, "severity: critical,high") { - hasBoundedReference = true - break - } - } - if !hasBoundedReference { - t.Fatalf("%s must include state: open and severity: critical,high near list_code_scanning_alerts", path) - } - }) - } -} From 4ea7df31fde1c19106e99fa6b619f031f7a73994 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 6 Jul 2026 14:18:10 +0000 Subject: [PATCH 6/6] Add bounded guidance to all list_code_scanning_alerts table mentions in SKILL.md Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com> --- .github/skills/github-mcp-server/SKILL.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/skills/github-mcp-server/SKILL.md b/.github/skills/github-mcp-server/SKILL.md index 33672d831cf..012181c22a0 100644 --- a/.github/skills/github-mcp-server/SKILL.md +++ b/.github/skills/github-mcp-server/SKILL.md @@ -108,7 +108,7 @@ The following toolsets are enabled by default when `toolsets:` is not specified: | `issues` | Issue management | `issue_read`, `list_issues`, `create_issue`, `search_issues` | | `pull_requests` | Pull request operations | `pull_request_read`, `list_pull_requests`, `create_pull_request` | | `actions` | GitHub Actions/CI/CD | `list_workflows`, `list_workflow_runs`, `download_workflow_run_artifact` | -| `code_security` | Code scanning and security | `list_code_scanning_alerts`, `get_code_scanning_alert` | +| `code_security` | Code scanning and security | `list_code_scanning_alerts` ⚠️ (always include `state: open` and `severity: critical,high`), `get_code_scanning_alert` | | `dependabot` | Dependency management | Dependabot alerts and updates | | `discussions` | GitHub Discussions | `list_discussions`, `create_discussion` | | `experiments` | Experimental features | Unstable/preview APIs | @@ -294,7 +294,7 @@ Use this table to identify which toolset contains the tools you need: | `issue_read`, `list_issues`, `create_issue`, `update_issue`, `search_issues` | `issues` | | `pull_request_read`, `list_pull_requests`, `create_pull_request` | `pull_requests` | | `list_workflows`, `list_workflow_runs`, `get_workflow_run` | `actions` | -| `list_code_scanning_alerts`, `get_code_scanning_alert` | `code_security` | +| `list_code_scanning_alerts` ⚠️ (always include `state: open` and `severity: critical,high`), `get_code_scanning_alert` | `code_security` | | `list_discussions`, `create_discussion` | `discussions` | | `get_label`, `list_labels`, `create_label` | `labels` | | `get_user`, `list_users` | `users` |