Skip to content

feat(mcp): add per-call content parameter to search/find_related (semble#247) - #99

Merged
amondnet merged 3 commits into
mainfrom
amondnet/parity-add-per-call-content-parameter-to-mcp-sea
Sep 4, 2026
Merged

feat(mcp): add per-call content parameter to search/find_related (semble#247)#99
amondnet merged 3 commits into
mainfrom
amondnet/parity-add-per-call-content-parameter-to-mcp-sea

Conversation

@amondnet

@amondnet amondnet commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports upstream MinishLab/semble#247 (9218491): the MCP search and find_related tools now accept a per-call content argument (code | docs | config | all). Omitting it keeps the server's --content default, so existing clients are unaffected.

  • csp::mcp — new ContentSelection enum (serde lowercase; schemars::JsonSchema under the cli feature) and resolve_content_selection (None → server default, all → every ContentType), mirroring upstream _resolve_content_selection.
  • IndexCache — keyed on CacheKey { source, content } with content normalized to enum order and de-duplicated (upstream _CacheKey = (source_key, tuple[ContentType, ...])). The same repo searched as code and as docs holds two independent session entries; get / evict and fingerprint revalidation take the content slice. IndexCache::new() no longer takes a content list (the server holds default_content).
  • ContentType derives Hash so it can sit in the cache key.
  • rmcp transportcontent: Option<ContentSelection> on SearchParams / FindRelatedParams; the schema advertises the four values.
  • No on-disk changeindexing/cache.rs::resolve_cache_dir already hashes sourceId + content + ref, so upstream's index-<scope> sibling-dir change in cache.py has no csp counterpart.
  • DocsSERVER_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, different content → 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 through CspMcpServer: a code-only server on a repo with sample.ts + README.md returns only sample.ts by default, only README.md for content: "docs", both for all, and holds three cache entries afterwards.

cargo fmt --all && cargo clippy --all-targets --all-features -- -D warnings && cargo test --workspace pass (312 lib + 25 bin). bun run lint passes.

Related issue

Closes #85

Checklist

  • PR title follows Conventional Commits
  • Tests added or updated, and the suite passes (mise run test)
  • Lint/format pass (mise run lint)
  • Documentation updated if behavior changed
  • No breaking change, or a BREAKING CHANGE: note is included — the public lib signature of IndexCache::new / get / evict / search_tool / find_related_tool gained a content argument; the wire (MCP) surface is backward compatible.

Summary by cubic

Adds a per-call content parameter to the MCP search and find_related tools. Previously both tools used only the server’s --content setting; calls can now select code, docs, config, or all, while omitted values keep the server default.

Written for commit 90a290b. Summary will update on new commits.

…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
@codacy-production

codacy-production Bot commented Sep 4, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 24 complexity · 0 duplication

Metric Results
Complexity 24
Duplication 0

View in Codacy

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/csp/src/mcp.rs
@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.12734% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/csp/src/mcp.rs 98.07% 3 Missing ⚠️
crates/csp/src/bin/csp/mcp_server.rs 98.19% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 5 untouched benchmarks


Comparing amondnet/parity-add-per-call-content-parameter-to-mcp-sea (90a290b) with main (b2de30d)

Open in CodSpeed

@amondnet
amondnet marked this pull request as ready for review September 4, 2026 14:02
@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds an optional per-call content scope to the MCP search tools while preserving the server-configured scope as the default.

  • Adds lowercase code, docs, config, and all content selections to both MCP tool contracts.
  • Keys in-memory indexes by normalized source and content selection, with matching content-aware freshness checks.
  • Updates MCP instructions, user documentation, and tests for selection resolution, schema exposure, cache separation, and end-to-end searching.

Confidence Score: 5/5

The 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.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "feat(mcp): add per-call `content` parame..." | Re-trigger Greptile

@amondnet

amondnet commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/csp/src/bin/csp/mcp_server.rs Outdated
@amondnet

amondnet commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

@amondnet
amondnet merged commit ee45529 into main Sep 4, 2026
13 checks passed
@amondnet
amondnet deleted the amondnet/parity-add-per-call-content-parameter-to-mcp-sea branch September 4, 2026 14:20
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.

parity(#247): add per-call content parameter to MCP search/find_related and key the session cache on it

1 participant