Repository navigation
docs(mcp): document execute_query max_rows default and result semantics - #129
Merged
Merged
Conversation
The MCP execute_query tool defaults to max_rows=100 while the CLI shows every row unless -n is given, and the MCP guides never mentioned max_rows or explained the total/returned/device_id/rows fields. An agent following the guide could read 100 rows and treat them as the complete result. Add a "Query Results and Row Limits" section to docs/en/mcp.md and docs/zh/mcp.md covering the field meanings, the deliberate CLI/MCP default difference, that total stays exact when the cap is hit, and how to lift or page past the cap; note the default in the tools table and fix the example return shape to include device_id. Cross-reference from the querying guides' output-format sections. Pin the behavior with an MCP test that inserts 150 leak candidates and checks returned == 100, total == 150, and max_rows=0 returning everything. Fixes #123
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
The MCP
execute_querytool is declared asexecute_query(template, params=None, device_id=None, max_rows: int = 100), so it returns at most 100 rows by default, whilept-snap queryprints every row unless-nis given. Neitherdocs/en/mcp.mdnordocs/zh/mcp.mdmentionedmax_rows, and neither explained thetotal/returned/device_id/rowsfields. An agent following the guide could read 100 rows and treat them as the complete result (for example when summing leaked bytes), unless it happened to noticetotal > returned.The default difference is intentional (it keeps a large result from flooding an agent's context); it just needed to be written down. Same class of drift as #91 / #94.
Changes:
docs/en/mcp.md,docs/zh/mcp.md: new Query Results and Row Limits / 查询结果与行数限制 section with a field table, the CLI vs. MCP default difference, thattotalstays exact when the cap is hit (the service runs aCOUNT(*)), thereturned < totalpattern with a paging example, and themin(limit, max_rows)interaction for templates that exposelimit. The tools table row now states the default, and the example return shape includesdevice_id(which the tool actually returns).docs/en/querying.md,docs/zh/querying.md: one-sentence cross-reference from the-n/ output-format section back to the MCP behavior.tests/test_mcp_server.py:test_execute_query_default_max_rows_caps_rows_but_keeps_exact_totalinserts 150 leak candidates and assertsreturned == 100,total == 150, and thatmax_rows=0returns all 150 — so the documented behavior is pinned and future drift shows up in CI.No production code changes.
🔗 Related Issue
Fixes #123
🧪 Testing
pytest tests/test_mcp_server.py tests/test_contract_cli_mcp.py: 24 passed.pytest tests/test_governance.py: 26 passed. Full suite (macOS, Python 3.13.11):770 passed, 1 xfailed. Section anchors used by the cross-references exist in both languages.ruff check ./black --check .clean.✅ Checklist
Snapshot Runtime Provenance
Snapshot provenance decision: no-update
Snapshot provenance no-update reason: This PR changes only user documentation under docs/ and one MCP test; no files under src/pt_snap_cli/snapshot/ are touched.
📋 Additional Notes
docs/en/anddocs/zh/were updated together to keep the behavioral descriptions aligned, perAGENTS.mdDocumentation Boundaries.