Repository navigation
feat(mcp-server-supabase): add level filter and per-lint findings cap to get_advisors - #574
francis-codex wants to merge 1 commit into
Conversation
… to get_advisors Projects with many distinct findings still produce oversized get_advisors responses after supabase#390 grouped repeated lints, because every group carries its full findings list. Add two optional inputs: - level: keep only ERROR, WARN or INFO lints (applied before grouping) - max_findings_per_lint: cap the findings listed under each lint; count keeps the true total and findings_omitted reports what was cut The cap is per lint rather than global so a long tail of one lint cannot crowd every other lint out of the response. Default output is unchanged. Refs supabase#124
|
Thanks for the credit, go ahead. |
|
thanks brian, appreciate it. will ping you if the review turns up anything on the cap. |
|
@gregnr ready for review when you have a moment. this adds an optional |
|
Thanks for picking this up, and for crediting Brian's proposal! The change itself looks good. We're holding it for now because #546 adds |
|
hey, what if keep the filter and cap only in get_issues and leave get_advisors as it is. #546 already has both: New inputs on get_advisors wouldn't reach anyone that get_issues doesn't. Once #546 ships, a client that re-reads tools/list also sees get_issues, and the frozen ChatGPT snapshot sees neither. The cost of that choice is that get_advisors stays uncapped until it is removed. And in get_issues the cap is per issue, so the total still grows with the number of issues: on a synthetic project shaped like the Mockamaster capture (11 issues, 547 findings), the default call came out at 65-85k characters. About a quarter of that is the same docs_url repeated on every finding. |
|
@barryroodt agree with brian, the cap belongs in get_issues. happy to close this once #546 lands so there's one place to maintain. to help #546 along, i'll take the eval mattrossman asked for in supabase/evals: a large-project scenario (Mockamaster-shaped, 500+ findings) that has to pass with get_issues and stay under a set output size, run through the #514 local-repo flow. @Brian-1812 that pairs with your docs_url move and size test, so we don't overlap |
…on eval Adds 10 Supabase database linter checks to platform-lite (security: policy_exists_rls_disabled, rls_enabled_no_policy, security_definer_view, function_search_path_mutable, materialized_view_in_api; performance: unindexed_foreign_keys, auth_rls_initplan, no_primary_key, multiple_permissive_policies, duplicate_index). The performance advisor now returns real lints instead of an empty list. rls_disabled_in_public remediation is now the docs URL, matching the hosted API. New regression eval investigate-database-001-large-advisor-backlog seeds a Mockamaster-shaped project: 547 findings in 11 issues, 8 at warning or worse, and 3 critical issues that all trace to public.payments having RLS disabled. It checks get_issues was called, its output stayed under 100k chars without harness truncation, and the agent ranked enabling RLS on public.payments first. The experiment pins supabase/mcp at a0137116 (supabase#546 head) so it runs without a local MCP checkout. Drop the pin once get_issues ships. Refs supabase/mcp#546, supabase/mcp#574
|
updated supabase/evals#552 so it matches mockamaster and runs without a local mcp checkout.
once docs_url moves to issue level, the default size here should drop. i'll re-measure then. |
|
Agreed, @Brian-1812. I'm closing this PR and keeping the filter + cap in #546 has merged and we're releasing it today. Its Thanks for the clean change, @francis-codex! I had no concerns with the code. Brian, I got similar numbers on #546. Dropping the per-finding |
## What kind of change does this PR introduce? Bug fix (response size). Follow-up to #546, as @barryroodt asked on #574 ([comment](#574 (comment))). Refs #124. ## What is the current behavior? Every finding in `get_issues` repeats its issue's `docs_url`. In splinter, each lint has one fixed remediation link, so these copies add no data for splinter lints. On a project the size of the Mockamaster capture in #546 (547 findings in 11 issues), the copies are about 22% of the default response. ## What is the new behavior? Findings no longer carry `docs_url`. The issue keeps its `docs_url`, so every finding still reaches the link through its issue. Nothing else in the output changes. | Call | Before | After | Saved (chars / tokens) | |---|---:|---:|---:| | default | 62,296 chars, 15,225 tokens | 48,243 chars, 11,614 tokens | 22.6% / 23.7% | | `severity: warning` | 43,789 chars, 10,533 tokens | 34,836 chars, 8,252 tokens | 20.4% / 21.7% | I ran the real splinter SQL in PGlite on the supabase/evals#552 seed and fed the lints to the real `get_issues` on `main`. Splinter also flags 41 unused indexes there, because a fresh database has no index scans. I left those out to match 547 findings in 11 issues. With them, the default call goes from 69,279 to 53,346 chars (23.0%). Tokens are OpenAI `o200k_base`; I did not count Claude tokens. In every call I ran, each removed link was equal to its issue's link, and the rest of the output is byte-identical. There is exactly one way this change can lose data: two findings of the same lint with different docs links, where the second link is now gone. I checked splinter at [`cc529aa9`](https://github.com/supabase/splinter/blob/cc529aa9d3eeffd2e64576c7591e60b22abd205c/splinter.sql): each of its 31 lints has one constant remediation, so this can't happen there. I can't see the platform-only and health lints, though: can you confirm that none of them gives two findings of one lint different links? ## How to Review 1. **Output contract** - `packages/mcp-server-supabase/src/issues.ts` - `docs_url` leaves the finding schema and the finding object. The issue-level `docs_url` does not change. `get_issues` uses this schema as its output schema, so `tools/list` changes too. 2. **Tests** - `packages/mcp-server-supabase/src/server.debugging.test.ts`: a new size test calls `get_issues` through the server harness on 547 findings in 11 issues. The default response must stay under `LARGE_PROJECT_ISSUES_BUDGET` (48,000 chars). - `packages/mcp-server-supabase/src/issues.test.ts`: one #546 test gave two findings of one issue different links. It now checks the issue's link, and that a finding has no `docs_url`. **Review questions** - [ ] Is 48,000 chars a good budget? It is about 10% above today's 43,493 for this fixture, so it catches growth early. It is well under the 25,000-token limit from #124. - [ ] If a platform-only or health lint can give different links (question above), should I keep `docs_url` on a finding only when it differs from the issue's link? - [ ] Should this land before the release in #586? Then no published version has `docs_url` on findings. - [ ] Do the tests check output, not implementation details? ## Verification - With `main`'s `issues.ts`, the new size test fails with `expected 56866 to be less than 48000`. On this branch it passes at 43,493. - `pnpm format:check`, `tsc --noEmit`, and `vitest run --project unit`: 1028/1028 passed. ## Additional context This changes the `get_issues` output schema: `issues[].affected[]` no longer has `docs_url`. So it is best merged before that schema goes into a ChatGPT submission. If #586 merges first, the field is in a published release. Then I will mark the commit as breaking, as CONTRIBUTING asks for a contract step. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
What kind of change does this PR introduce?
Feature: two optional inputs on
get_advisors.What is the current behavior?
Closes #124.
#390 grouped repeated lints, which fixed the "same lint 300 times" case. Projects with many distinct findings still get oversized responses, because each group carries its full
findingslist. The agent has no way to ask for less, so it either truncates client-side or gives up on the tool.What is the new behavior?
Implements the shape @Brian-1812 proposed in #124:
level(ERROR|WARN|INFO): keeps only lints at that level. Applied before grouping, socountreflects the filtered set.max_findings_per_lint(int >= 1): caps the findings listed under each grouped lint.countkeeps the true total andfindings_omittedis added only when something was cut.The cap is per lint instead of one global
limit. A global cap applied in order lets one noisy lint (e.g. 200unused_index) fill the budget and hide anERRORlint further down. Per lint, every lint type stays visible and the response size is bounded bylint types × cap.With neither input set the output is byte-identical to today. Unknown response shapes still pass through untouched.
How to Review
Result shaping
packages/mcp-server-supabase/src/tools/debugging-tools.tsgroupAdvisorsResultnow takes options: filter, thengroupAdvisorLints, thencapFindings. The schema changes are ongetAdvisorsInputSchema, and the legacy schema inherits them through.extend.Tests
packages/mcp-server-supabase/src/server.debugging.test.tsfindings_omitted: 1, and a group under the cap that gets nofindings_omittedkey.Review questions
max_findings_per_lintthe right name, or would you rather keeplimitfrom the issue thread?findings_omittedalways be present (as0) for a stable shape, or only when non-zero as here?lintsshape. Any type where you'd rather not expose them?Verification
No eval added. Happy to add one if you'd like the size reduction measured on a seeded project.
Additional context
@Brian-1812 offered to take this on 11 Nov. I've used his proposed API and credited it here. If you already have a branch, I'm glad to close this in favour of yours.