Skip to content

feat(mcp): support query-scoped facets - #1569

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/mcp-query-scoped-facets
May 25, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/mcp-query-scoped-facets

Conversation

@Sinity

@Sinity Sinity commented May 25, 2026

Copy link
Copy Markdown
Owner

Summary

MCP facets now exposes the shared optional query field, 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 whether query is included from whether it is required: search keeps query required, while facets exposes it as optional. The MCP query schema derivation tests now cover facets, 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 passed
  • devtools verify --json → PASS, 1 affected pytest node selected
  • pre-push devtools verify --quick → PASS

Ref #873

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
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've used your available PR reviews for now.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 81626d7f-d1a6-4e24-be8e-23af0ee126c8

📥 Commits

Reviewing files that changed from the base of the PR and between 7265ef0 and e1c92d7.

📒 Files selected for processing (4)
  • polylogue/mcp/query_contracts.py
  • polylogue/mcp/server_tools.py
  • tests/data/witnesses/mcp-tool-schemas.json
  • tests/unit/mcp/test_query_tool_schema_derivation.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/mcp-query-scoped-facets

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit d575ede into master May 25, 2026
6 checks passed
@Sinity
Sinity deleted the feature/feat/mcp-query-scoped-facets branch May 25, 2026 10:10
Sinity added a commit that referenced this pull request May 25, 2026
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant