Repository navigation
Add list_code_quality_findings tool to code_quality toolset - #3564
Conversation
Add a read-only tool that lists code quality findings for a repository
via GET /repos/{owner}/{repo}/code-quality/findings. It supports the
endpoint's filters: state (open or dismissed, defaulting to open),
direction (asc or desc), and cursor pagination (perPage, after).
The tool follows the list_dependabot_alerts pattern: cursor pagination
schema, defaults stripped from the validation schema, a typed output
with findings and pageInfo, and the same scopes as
get_code_quality_finding. Like get_code_quality_finding, it attaches
no IFC label.
Includes unit tests, the tool snapshot, and regenerated README docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The endpoint sorts findings by creation date only, so describe the direction values in those terms. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Every tool must be covered by a bundled skill or explicitly exempted. Add list_code_quality_findings as an optional tool of the repository-health-review skill, next to the code scanning and Dependabot alert tools, and mention it in the outstanding-risk step. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| } | ||
|
|
||
| response := struct { | ||
| Findings json.RawMessage `json:"findings"` |
There was a problem hiding this comment.
This is a known potential issue, but from what I can see in other tools we have there's no perfect fix for it. It looks like the metadata wrapping this autofix is suggesting was rejected in other PRs. Notably this tool will only return findings from the default branch of the repository at this time, so any malicious instructions would have to be placed by folks with permission to write code to the repo.
Label successful results with ifc.LabelSecurityAlert() (private, untrusted) when the ifc_labels feature flag is enabled, the same label the code scanning, Dependabot and secret scanning tools use. Findings embed file paths and messages derived from repository code, and without a label, clients that enforce IFC have no classification for this data. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| return utils.NewToolResultErrorFromErr("failed to marshal findings", err), CodeQualityFindingsOutput{}, nil | ||
| } | ||
|
|
||
| result := utils.NewToolResultText(string(r)) |
There was a problem hiding this comment.
This is a known potential issue, but from what I can see in other tools we have there's no perfect fix for it. The suggested fix drops the findings from the text output, which breaks clients that read text instead of structured content; the same change was declined in #3719. Notably this tool will only return findings from the default branch of the repository at this time, so any malicious instructions would have to be in code that someone with write access has merged into the default branch.
There was a problem hiding this comment.
Yeah, Copilot is being a bit extra here. Don't worry about that.
There was a problem hiding this comment.
🔵 Needs a closer look
The tool’s protocol-dependent outputs, cursor pagination, and restricted findings with feature-gated IFC metadata require broader review of interacting data-access and compatibility contracts.
No open issues 🎉
What changed in this PR
Adds list_code_quality_findings to the existing code_quality toolset, letting agents discover findings without knowing their numbers first, addressing #3560.
Changes:
- Adds read-only listing with state and sort-direction filters, cursor pagination, and private/untrusted labels when enabled.
- Supports legacy JSON responses and typed outputs, with behavioral, compatibility, and schema tests.
- Documents the tool and integrates it into the repository-health-review skill.
| File | Description |
|---|---|
| README.md | Documents the new tool and its inputs. |
| pkg/skills/catalog/tools.go | Adds the tool as an optional repository-health capability. |
| pkg/skills/catalog/skills/repository-health-review/SKILL.md | Includes code quality findings in risk assessment. |
| pkg/github/typed_security_outputs_test.go | Tests typed output and legacy field preservation. |
| pkg/github/typed_security_compatibility_test.go | Covers filters, empty results, errors, and protocol compatibility. |
| pkg/github/tools.go | Registers the new tool. |
| pkg/github/security_outputs.go | Defines listing input and output types. |
| pkg/github/helper_test.go | Adds the mock listing endpoint. |
| pkg/github/code_quality.go | Implements listing, pagination, error handling, and result labeling. |
| pkg/github/code_quality_test.go | Tests tool metadata, requests, pagination, labels, and errors. |
| pkg/github/__toolsnaps__/list_code_quality_findings.snap | Records the tool’s input and output schemas. |
Review effort: Balanced (adaptive)
tjgurwara99
left a comment
There was a problem hiding this comment.
This looks good to me! Still it might be ideal to get some eyes from the owners/maintainers of this repo too 😄
|
Merged, but just did a release, so it might be a few days before it hits remote server 🙏 |
Bring in 7edc2dd (list_code_quality_findings, github#3564). The README catalog addition does not overlap the go install section. Go lines stay at 1.27.4. Co-authored-by: ango <nanami7777777@users.noreply.github.com>
Summary
Adds a read-only
list_code_quality_findingstool to thecode_qualitytoolset. It lists a repository's code quality findings throughGET /repos/{owner}/{repo}/code-quality/findingsand supports thestateanddirectionfilters plus cursor pagination.Why
Closes #3560
What changed
ListCodeQualityFindingsinpkg/github/code_quality.go, modelled onlist_dependabot_alerts:WithCursorPagination(perPage,after) andNewToolWithSchemaOptions, withValidationInputSchema: inventory.CloneSchemaWithoutDefaults(schema).ReadOnlyHint: true.TOOL_LIST_CODE_QUALITY_FINDINGS_*.ownerandrepoare required.stateacceptsopenordismissedand defaults toopen.directionacceptsascordescand defaults todesc. These are the only filters the endpoint supports.CodeQuality.ListFindings, but the tool sends a rawclient.NewRequestto matchGetCodeQualityFindingand to return the REST JSON unchanged to legacy clients.ListCodeQualityFindingsInputandCodeQualityFindingsOutput(findingspluspageInfo) topkg/github/security_outputs.go:pageInfo.CodeQualityFindingOutputDTO.pkg/github/tools.go, right afterGetCodeQualityFinding.ifc_labelsfeature flag is on, successful results carry theifc.LabelSecurityAlert()IFC label (private, untrusted), the same label the code scanning, Dependabot and secret scanning tools use.Test_ListCodeQualityFindingscovers the toolsnap, schema assertions, defaults, the state and direction filters, cursor passthrough, the returned next cursor, the IFC label, 403 and 404 responses, and missingownerorrepo.Linkheader includes arel="last"link with an emptybefore=value. pageInfo reads cursors only fromrel="next"andrel="prev", so it never returns that empty cursor. A test using the real header shape covers this.list_code_quality_findings.snap, and the README is regenerated.repository-health-reviewbundled skill: added it to the skill's optional tools inpkg/skills/catalog/tools.goand to the skill's outstanding-risk step, next to the code scanning and Dependabot alert tools.MCP impact
list_code_quality_findings. It is in the existingcode_qualitytoolset. There is no feature flag, and the default toolsets are unchanged.Prompts tested (tool changes only)
I tested these against a local build over stdio, using a repository that has Code Quality enabled.
hasNextPage: true, and anextCursor.after): returns the next 5 findings in the same order as the REST API, with both cursors.direction: asc): returns findings in ascending order.failed to list findings for repository 'github/github-mcp-server': ... 403 Code quality is not enabled for this repository. Please enable code quality in the repository settings.state: closed: schema validation rejects it.Security / limits
get_code_quality_finding:scopes.PublicRead(scopes.Repo), which needs therepoOAuth scope for private repositories.ifc_labelsfeature flag on, results carry theifc.LabelSecurityAlert()IFC label, like the code scanning, Dependabot and secret scanning tools. Findings include file paths and messages derived from repository code, so they are marked untrusted. They are marked private because only users with write access can view findings (docs). I confirmed on a live call that the label appears with the flag on and is absent with it off.get_code_quality_findingstill has no IFC label (it merged just after labels were added to the read tools). That can be fixed in a follow-up.Tool renaming
deprecated_tool_aliases.goNote: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.
Lint & tests
./script/lint: passed, 0 issues../script/test: passed after mergingmain, includinggo test ./pkg/skills/catalog -run TestCatalogToolRequirementsAreRegistered -count=1.UPDATE_TOOLSNAPS=true go test ./...also passed; it added one new snapshot and changed no others.Docs
script/generate-docs. The only change is the new tool entry.Skills
list_code_quality_findingsto therepository-health-reviewskill as an optional tool, next tolist_code_scanning_alertsandlist_dependabot_alerts. The skill's outstanding-risk step now counts open code quality findings byrule.severity.