Repository navigation
feat(mcp): support query-scoped facets - #1569
Conversation
Problem: #873 expects scoped facets to be available consistently across CLI, API, daemon HTTP, and MCP. The MCP facets tool still omitted the shared query field from its generated wire schema, so clients could only ask for global/filter facets and could not request query-scoped counts. What changed: split the shared MCP query signature builder so search keeps query required while facets exposes the same query field as optional. Extended schema derivation tests to include facets and regenerated the committed MCP tool schema witness. Verification: pytest -q tests/unit/mcp/test_tool_schema_witness.py tests/unit/mcp/test_query_tool_schema_derivation.py --tb=short; devtools verify --json. Ref #873
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 22 minutes and 9 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ 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 Adds a focused runtime contract for the MCP `facets` tool so the query-scoped facets surface is pinned beyond the published schema witness. ## Problem #873 requires scoped facets across CLI/API/daemon/MCP. #1569 exposed `query` in the MCP facets input schema, but a regression could still accept the parameter and then drop it before calling the shared `Polylogue.facets()` contract. ## Solution The new MCP facets contract test invokes the registered tool with `query` + `provider` and asserts that it forwards a `ConversationQuerySpec` carrying both filters. It also covers the no-filter path and asserts that MCP calls `poly.facets(None)` for the global view. ## Verification - `pytest -q tests/unit/mcp/test_facets_tool_contract.py tests/unit/mcp/test_query_tool_schema_derivation.py --tb=short` → 9 passed - `ruff format --check tests/unit/mcp/test_facets_tool_contract.py tests/unit/mcp/test_tool_contracts.py` → passed - `ruff check tests/unit/mcp/test_facets_tool_contract.py tests/unit/mcp/test_tool_contracts.py` → passed - `mypy tests/unit/mcp/test_facets_tool_contract.py tests/unit/mcp/test_tool_contracts.py` → passed - `devtools verify --json` → PASS, 66 affected pytest nodes selected - pre-push `devtools verify --quick` → PASS - PR CI → Analyze (python), CodeQL, GitGuardian passed Ref #873
Summary
MCP
facetsnow exposes the shared optionalqueryfield, so clients can request query-scoped facet counts through the same typed request contract used by CLI/API/daemon surfaces.Problem
#873 expects scoped facets to be available consistently across the public read surfaces. CLI, API, and daemon HTTP already accepted query-scoped facet requests, but the MCP tool signature explicitly omitted
query, leaving agent clients with only global/filter facets.Solution
conversation_query_request_signature()now distinguishes whetherqueryis included from whether it is required:searchkeepsqueryrequired, whilefacetsexposes it as optional. The MCP query schema derivation tests now coverfacets, and the committed MCP tool-schema witness was regenerated to preserve the published wire contract.Verification
pytest -q tests/unit/mcp/test_tool_schema_witness.py tests/unit/mcp/test_query_tool_schema_derivation.py --tb=short→ 10 passeddevtools verify --json→ PASS, 1 affected pytest node selecteddevtools verify --quick→ PASSRef #873