fix(mcp): skip project filter for scope=personal with no explicit project#425
Merged
Merged
Conversation
…ject When scope=personal is passed to handleSearch or handleContext without an explicit project argument, the cwd-detected project was still applied as a store-level filter, hiding personal memories from other projects. Clear the project filter before calling s.Search / s.FormatContext whenever scope=personal and no per-call project override is present. The envelope project (used for UI context) is preserved unchanged. Closes #391
There was a problem hiding this comment.
Pull request overview
This PR fixes MCP read tools (mem_search, mem_context) so that when scope=personal is requested without an explicit project argument, the store query no longer applies the cwd-/process-detected project filter, allowing personal memories to surface cross-project as intended (closes #391).
Changes:
- In
handleSearch, route the store search through a clearedProjectfilter whenscope=personaland no per-call project override is present. - In
handleContext, route context formatting through a clearedprojectargument under the same condition. - Add regression tests covering cross-project visibility for
scope=personalin both handlers.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
internal/mcp/mcp.go |
Clears the project filter for store read calls when scope=personal and no explicit project override is provided. |
internal/mcp/mcp_test.go |
Adds tests ensuring scope=personal reads return personal content across projects when project is omitted. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+923
to
+926
| searchProject := project | ||
| if scope == "personal" && strings.TrimSpace(projectOverride) == "" { | ||
| searchProject = "" | ||
| } |
Comment on lines
+1385
to
+1388
| contextProject := project | ||
| if scope == "personal" && strings.TrimSpace(projectOverride) == "" { | ||
| contextProject = "" | ||
| } |
| activity.RecordToolCall(sessionID) | ||
|
|
||
| contextResult, err := s.FormatContext(project, scope) | ||
| contextResult, err := s.FormatContext(contextProject, scope) |
Comment on lines
+6561
to
+6562
| // Simulate cwd being project-alpha's directory; the handler should NOT filter | ||
| // results to project-alpha when scope=personal is requested without an explicit project. |
| t.Fatalf("add personal observation ctx-beta: %v", err) | ||
| } | ||
|
|
||
| // Simulate cwd being ctx-alpha's directory. |
…oss-project # Conflicts: # internal/mcp/mcp_test.go
…oss-project # Conflicts: # internal/mcp/mcp_test.go
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.
Summary
handleSearchandhandleContextauto-detected the cwd project and applied it as a store-level filter even whenscope=personalwas requested without an explicitproject, hiding personal memories from other projects.Fix: clear the project filter before
s.Search/s.FormatContextwhenscope=personaland no per-call project override is present. The envelopeprojectfield (UI context) is preserved.Test plan
TestHandleSearchPersonalScopeIgnoresCWDProjectandTestHandleContextPersonalScopeIgnoresCWDProjectininternal/mcp/mcp_test.goproject=withscope=personalstill filters to the named project (preserved)go test ./... && go vet ./... && go build ./...cleanCloses #391