fix(mcp): apply default row cap in list_stored_queries markdown fallback#2526
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesStored query fallback limits
Estimated code review effort: 2 (Simple) | ~5 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
list_stored_queries's markdown fallback applies no default row cap, while the LanceDB path ten lines above defaults toMAX_ROW_LIMIT. Withlimitomitted, the fallback returns the entireknowledge/sqlcorpus.Motivation
Both paths live in the same handler and disagree:
Every other
MAX_ROW_LIMITsite guards:_query_with_limit_probemin(effective_limit, MAX_ROW_LIMIT)_query_cube_with_limit_probemin(effective_limit, MAX_ROW_LIMIT)list_stored_queries(LanceDB)limit if limit is not None else MAX_ROW_LIMITlist_stored_queries(fallback)Three of four obey the cap; the fourth doesn't.
Reachability is wider than "user didn't install the
memoryextra": theexcept Exceptioncatches anyMemoryStoreerror, so an installed-and-working setup that hits one transient failure silently switches from capped to uncapped and returns the whole corpus to the MCP client.Fix
This mirrors the sibling path's semantics exactly (default when omitted, honour an explicit
limit). I deliberately did not also align the other asymmetry — the probe helpers hard-cap withmin(...)whilelist_stored_queriestreatsMAX_ROW_LIMITas a default an explicit largerlimitcan exceed. Reconciling those two is a behaviour change to an existing API, not a bug fix, so it is out of scope here.Verification
tests/unit/test_mcp_server.py(covered by the dedicated CImcp testsjob):test_list_stored_queries_fallback_applies_default_cap— forces the fallback via a raising store,MAX_ROW_LIMITmonkeypatched to 3, 10 pairs available.assert 10 == 3— RED. With it: PASS.test_list_stored_queries_fallback_honours_explicit_limit— reverse anchor: an explicitlimit=2below the cap must still win.pairs[:MAX_ROW_LIMIT]reds it.mcp testsjob vs cleanmain, verbatim: 14 → 16 passed (+2 = exactly the new tests; 0 new failures). Lint clean (just lint).License
core/**is Apache-2.0 per the repo LICENSE path map — this contribution is within an Apache-2.0 path.Summary by CodeRabbit
Bug Fixes
Tests