Skip to content

fix(mcp): skip project filter for scope=personal with no explicit project#425

Merged
Alan-TheGentleman merged 3 commits into
mainfrom
fix/personal-scope-cross-project
May 27, 2026
Merged

fix(mcp): skip project filter for scope=personal with no explicit project#425
Alan-TheGentleman merged 3 commits into
mainfrom
fix/personal-scope-cross-project

Conversation

@Alan-TheGentleman

Copy link
Copy Markdown
Collaborator

Summary

handleSearch and handleContext auto-detected the cwd project and applied it as a store-level filter even when scope=personal was requested without an explicit project, hiding personal memories from other projects.

Fix: clear the project filter before s.Search / s.FormatContext when scope=personal and no per-call project override is present. The envelope project field (UI context) is preserved.

Test plan

  • TestHandleSearchPersonalScopeIgnoresCWDProject and TestHandleContextPersonalScopeIgnoresCWDProject in internal/mcp/mcp_test.go
  • Explicit project= with scope=personal still filters to the named project (preserved)
  • go test ./... && go vet ./... && go build ./... clean

Closes #391

…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
Copilot AI review requested due to automatic review settings May 27, 2026 14:43
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label May 27, 2026

Copilot AI 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.

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 cleared Project filter when scope=personal and no per-call project override is present.
  • In handleContext, route context formatting through a cleared project argument under the same condition.
  • Add regression tests covering cross-project visibility for scope=personal in 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 thread internal/mcp/mcp.go
Comment on lines +923 to +926
searchProject := project
if scope == "personal" && strings.TrimSpace(projectOverride) == "" {
searchProject = ""
}
Comment thread internal/mcp/mcp.go
Comment on lines +1385 to +1388
contextProject := project
if scope == "personal" && strings.TrimSpace(projectOverride) == "" {
contextProject = ""
}
Comment thread internal/mcp/mcp.go
activity.RecordToolCall(sessionID)

contextResult, err := s.FormatContext(project, scope)
contextResult, err := s.FormatContext(contextProject, scope)
Comment thread internal/mcp/mcp_test.go
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.
Comment thread internal/mcp/mcp_test.go
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
Copilot AI review requested due to automatic review settings May 27, 2026 14:54
@Alan-TheGentleman Alan-TheGentleman merged commit 9ae9acf into main May 27, 2026
5 of 6 checks passed
@Alan-TheGentleman Alan-TheGentleman deleted the fix/personal-scope-cross-project branch May 27, 2026 14:56
@Alan-TheGentleman Alan-TheGentleman removed the request for review from Copilot May 27, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(mcp): scope=personal still filters by current project, blocking cross-project memory visibility

2 participants