feat(mcp): minimal mem_find_project tool - #661
Conversation
📝 WalkthroughWalkthroughAdds project-level memory relevance search through the ChangesProject relevance search
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant MCPClient
participant handleFindProject
participant Store
MCPClient->>handleFindProject: query and match_mode
handleFindProject->>Store: SearchProjects(query, match_mode, limit)
Store-->>handleFindProject: ranked ProjectMatch results
handleFindProject-->>MCPClient: formatted project list or tool error
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/mcp/mcp_test.go`:
- Line 2257: Expand the tests around mem_find_project beyond tool registration
by invoking its handler with deterministic fixtures. Cover a successful search
result, missing query, invalid match_mode, no results, and store failures,
asserting each response and error behavior; keep the existing registration
assertion intact.
In `@internal/mcp/mcp.go`:
- Line 1199: Update the result formatting in the mem_find_project output around
TopRank so nearby computed ranks remain distinguishable and the returned value
preserves sufficient numeric precision; replace the fixed two-decimal formatting
in the fmt.Fprintf call with a precision-preserving representation while keeping
the existing project and match-count fields unchanged.
In `@internal/store/store_test.go`:
- Around line 8834-8906: Expand TestSearchProjects to cover empty queries,
any-mode matching, exclusion of deleted or blank-project observations,
zero/limited result bounds, query-error propagation, and deterministic TopRank
ordering. Use the existing test store and search-related helpers to create each
scenario, assert expected results and errors, and retain the current all-mode
grouping assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: acd92883-37d2-4a57-a6eb-7e1c4f617217
📒 Files selected for processing (4)
internal/mcp/mcp.gointernal/mcp/mcp_test.gointernal/store/store.gointernal/store/store_test.go
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/store/store_test.go`:
- Around line 8944-8948: The relevance-ordering tests need assertions beyond
result counts. In internal/store/store_test.go:8944-8948, update the limit-one
case to assert the sole result is the controlled high-relevance project-b. In
internal/mcp/mcp_test.go:7490-7495, assert project-one appears before
project-two and that each formatted result includes its match count and rank:
field; both sites require direct deterministic test coverage.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a9ef7ddc-6485-40aa-80c0-41c2ed4f38c2
📒 Files selected for processing (3)
internal/mcp/mcp.gointernal/mcp/mcp_test.gointernal/store/store_test.go
| name: "limit restricts results", | ||
| query: "auth", | ||
| matchMode: "all", | ||
| limit: 1, // Should return only top 1 project | ||
| expectLen: 1, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Assert the relevance-ordering contract.
The PR requires mem_find_project to return projects ordered by relevance. These tests can pass if the store returns the wrong top project or the MCP handler reverses the ordered results.
internal/store/store_test.go#L8944-L8948: Assert that the controlled high-relevance fixture,project-b, is the single result forlimit: 1.internal/mcp/mcp_test.go#L7490-L7495: Assert thatproject-oneoccurs beforeproject-two, and assert each formatted result includes its match count andrank:field.
As per path instructions, **/*_test.go must provide deterministic coverage.
📍 Affects 2 files
internal/store/store_test.go#L8944-L8948(this comment)internal/mcp/mcp_test.go#L7490-L7495
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/store/store_test.go` around lines 8944 - 8948, The
relevance-ordering tests need assertions beyond result counts. In
internal/store/store_test.go:8944-8948, update the limit-one case to assert the
sole result is the controlled high-relevance project-b. In
internal/mcp/mcp_test.go:7490-7495, assert project-one appears before
project-two and that each formatted result includes its match count and rank:
field; both sites require direct deterministic test coverage.
Source: Path instructions
Draft PR for #304. Dropped the preview field to keep the diff tiny. It only returns
Project, MatchCount, and TopRank (using FTS5 bm25). All MCP tool count tests updated.
Summary by CodeRabbit
New Features
Bug Fixes
Fixes #304
Fixes #304