Skip to content

feat(mcp): add all_projects flag to mem_search#408

Merged
Alan-TheGentleman merged 1 commit into
Gentleman-Programming:mainfrom
carlosmoradev:feat/mem-search-all-projects
May 27, 2026
Merged

feat(mcp): add all_projects flag to mem_search#408
Alan-TheGentleman merged 1 commit into
Gentleman-Programming:mainfrom
carlosmoradev:feat/mem-search-all-projects

Conversation

@carlosmoradev
Copy link
Copy Markdown
Contributor

🔗 Linked Issue

Closes #303


🏷️ PR Type

  • type:feature — New feature

📝 Summary

  • Adds an optional all_projects boolean to the mem_search MCP tool.
  • When true, project detection is skipped and FTS5 runs without a project filter so the agent can recall context from any project.
  • Response envelope reports project_source: "all_projects" and empty project so callers can tell a cross-project search apart from a scoped one.

📂 Changes

File Change
internal/mcp/mcp.go Add all_projects arg to the mem_search schema; short-circuit project resolution in handleSearch when it is true.
internal/project/detect.go New SourceAllProjects = "all_projects" constant for the envelope contract.
internal/mcp/mcp_test.go Three tests: cross-project results, all_projects overrides project, default behavior still scoped. Shared seedCrossProjectMemories helper.
DOCS.md Document the new flag in the mem_search section.

🧪 Test Plan

  • Unit tests pass locally: go test ./...
  • E2E tests pass locally: go test -tags e2e ./internal/server/...
  • Manually verified the three new tests pass: go test ./internal/mcp/ -run 'TestHandleSearchAllProjects|TestHandleSearchWithoutAllProjects' -v

✅ Contributor Checklist

  • Linked an approved issue (Closes #303)
  • Added exactly one type:* label (type:feature)
  • Ran unit tests locally
  • Ran e2e tests locally
  • Updated DOCS.md to document the new flag
  • Commit follows conventional commits format
  • No Co-Authored-By trailers

💬 Notes for Reviewers

  • When both project and all_projects: true are supplied, all_projects wins. This is documented in the parameter description ("Ignored when all_projects=true") and covered by TestHandleSearchAllProjectsOverridesProjectArg. Happy to switch to a hard error if you prefer a stricter contract.
  • The envelope now reports project: "" for cross-project responses. If you'd rather have it omit the field entirely, that is a one-line change.

Adds an optional boolean argument to mem_search that bypasses project
detection and runs a global FTS5 search. Resolves the case where an
agent needs to recall context from a project whose key it does not
know.

When all_projects is true, the handler skips
resolveReadProjectWithProcessOverride entirely and passes an empty
project to Store.Search. The project argument is ignored in this mode;
documented and tested. The response envelope reports
project_source="all_projects" and an empty project so callers can
distinguish cross-project results from a scoped query.

Adds a new SourceAllProjects constant in internal/project to keep the
envelope contract typed and explicit.

Closes Gentleman-Programming#303
@carlosmoradev
Copy link
Copy Markdown
Contributor Author

Heads up: I do not have permission to add labels on this repo, so the type:feature label is missing. Whenever a maintainer can add it, the "Check PR Has type:* Label" gate will pass.

Copy link
Copy Markdown
Collaborator

@Alan-TheGentleman Alan-TheGentleman left a comment

Choose a reason for hiding this comment

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

Reviewed the diff against #303 in a fresh worktree. The all_projects flag is opt-in, the default mem_search path is untouched, scope filtering is orthogonal so there is no cross-scope leak, and the new tests cover the true, false, and override paths. Build and full mcp suite pass. Approving.

@Alan-TheGentleman Alan-TheGentleman merged commit 8572633 into Gentleman-Programming:main May 27, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(mcp): add all_projects flag to mem_search for cross-project search

2 participants