feat(mcp): add per-call content parameter to search/find_related (semble#247) - #99
Conversation
…emble#247) Both MCP tools now accept `content` (`code` | `docs` | `config` | `all`), defaulting to the server's `--content`. `ContentSelection` and `resolve_content_selection` mirror upstream `_resolve_content_selection`. `IndexCache` is keyed on `(source, normalized content)` so one repo searched as `code` and as `docs` holds two independent session entries; `get` / `evict` and fingerprint revalidation take the content slice. The disk cache already hashed content into its dir, so no on-disk layout change. Docs: SERVER_INSTRUCTIONS, README (en/ko) tool section, plugin README, semble.md §4.16. Closes #85
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 24 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request introduces support for per-call content selection (code, docs, config, or all) in the MCP tools (search and find_related). It updates the IndexCache to key entries by both the source and the normalized content selection, allowing independent cache entries for different content types of the same repository. It also updates the server handlers, documentation, and tests to support this feature. The feedback suggests using BTreeSet in normalize_content to simplify and make the de-duplication and sorting of content types more idiomatic.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds an optional per-call content scope to the MCP search tools while preserving the server-configured scope as the default.
Confidence Score: 5/5The PR appears safe to merge; no actionable correctness, security, compatibility, or repository-rule issue remains. Optional calls continue to use the existing server default, explicit selections reach content-specific indexes, and cache construction, lookup, and freshness checks consistently use the normalized selection.
|
| Filename | Overview |
|---|---|
| crates/csp/src/mcp.rs | Adds content selection resolution and content-aware, normalized session cache identities throughout the MCP core. |
| crates/csp/src/bin/csp/mcp_server.rs | Exposes the optional content parameter in both MCP tools and resolves omitted values against the server default. |
| crates/csp/src/types.rs | Makes ContentType hashable for use in content-aware cache keys. |
| README.md | Documents per-call MCP content overrides and their relationship to the server default. |
| README.ko.md | Adds corresponding Korean documentation for per-call MCP content selection. |
| plugins/csp/README.md | Documents content overrides for plugin users. |
| .please/docs/references/semble.md | Records the upstream parity behavior and content-aware cache design. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[MCP search or find_related call] --> B{content supplied?}
B -- No --> C[Use server default content]
B -- Yes --> D[Resolve code, docs, config, or all]
C --> E[Normalize content selection]
D --> E
E --> F[Build cache key from source, ref, and content]
F --> G{Fresh session entry?}
G -- Yes --> H[Search selected index]
G -- No --> I[Load or build content-specific index]
I --> J[Store session entry]
J --> H
Reviews (1): Last reviewed commit: "feat(mcp): add per-call `content` parame..." | Re-trigger Greptile
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for per-call content selection (code, docs, config, or all) in the MCP search and find-related tools. The IndexCache has been updated to key on both the source and the normalized content selection, allowing different content types for the same repository to be cached independently. Feedback was provided to make the schema verification test more robust by parsing the JSON schema and asserting on enum values directly using BTreeSet equality rather than relying on brittle string matching.
…eview suggestion)
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a per-call content selection parameter (code, docs, config, or all) to the MCP search and find-related tools, allowing clients to override the server's default content indexing configuration on a single call. To support this, the IndexCache has been updated to key entries by both source and normalized content selection, enabling independent caching of different content scopes for the same repository. Comprehensive unit tests and documentation updates have been added to verify and describe this new capability. There are no review comments to assess, and the implementation appears robust and well-tested, so I have no feedback to provide.
|



Summary
Ports upstream MinishLab/semble#247 (
9218491): the MCPsearchandfind_relatedtools now accept a per-callcontentargument (code|docs|config|all). Omitting it keeps the server's--contentdefault, so existing clients are unaffected.csp::mcp— newContentSelectionenum (serde lowercase;schemars::JsonSchemaunder theclifeature) andresolve_content_selection(None→ server default,all→ everyContentType), mirroring upstream_resolve_content_selection.IndexCache— keyed onCacheKey { source, content }withcontentnormalized to enum order and de-duplicated (upstream_CacheKey = (source_key, tuple[ContentType, ...])). The same repo searched ascodeand asdocsholds two independent session entries;get/evictand fingerprint revalidation take the content slice.IndexCache::new()no longer takes a content list (the server holdsdefault_content).ContentTypederivesHashso it can sit in the cache key.content: Option<ContentSelection>onSearchParams/FindRelatedParams; the schema advertises the four values.indexing/cache.rs::resolve_cache_diralready hashessourceId + content + ref, so upstream'sindex-<scope>sibling-dir change incache.pyhas no csp counterpart.SERVER_INSTRUCTIONS, README.md / README.ko.md tool section,plugins/csp/README.md,.please/docs/references/semble.md§4.16.Tests
cache_keys_on_content— same repo, differentcontent→ distinct entries; order/duplicates normalize to the same key; evicting one variant leaves the other.resolve_content_selection_maps_default_all_and_single,content_selection_deserializes_lowercase_only.params_accept_content_selection_and_reject_unknown,tool_schemas_advertise_content_enum.search_tool_call_honors_per_call_content— end-to-end throughCspMcpServer: a code-only server on a repo withsample.ts+README.mdreturns onlysample.tsby default, onlyREADME.mdforcontent: "docs", both forall, and holds three cache entries afterwards.cargo fmt --all && cargo clippy --all-targets --all-features -- -D warnings && cargo test --workspacepass (312 lib + 25 bin).bun run lintpasses.Related issue
Closes #85
Checklist
mise run test)mise run lint)BREAKING CHANGE:note is included — the public lib signature ofIndexCache::new/get/evict/search_tool/find_related_toolgained acontentargument; the wire (MCP) surface is backward compatible.Summary by cubic
Adds a per-call
contentparameter to the MCPsearchandfind_relatedtools. Previously both tools used only the server’s--contentsetting; calls can now selectcode,docs,config, orall, while omitted values keep the server default.(source, content)variant independently.IndexCache::new,get,evict,search_tool, andfind_related_toolfor the new content arguments.contentparameter to MCP search/find_related and key the session cache on it #85.Written for commit 90a290b. Summary will update on new commits.