Skip to content

fix(store): match legacy mixed-case project names in MCP search#427

Merged
Alan-TheGentleman merged 1 commit into
mainfrom
fix/mcp-search-empty-results
May 27, 2026
Merged

fix(store): match legacy mixed-case project names in MCP search#427
Alan-TheGentleman merged 1 commit into
mainfrom
fix/mcp-search-empty-results

Conversation

@Alan-TheGentleman
Copy link
Copy Markdown
Collaborator

Summary

  • Fixes MCP mem_search returning empty results while engram search (CLI) works for the same query and database.
  • Root cause: SQLite project = ? is case-sensitive. Legacy observations stored with mixed-case project names (e.g. Ebook2Audio) are invisible to normalized lowercase queries (ebook2audio). The MCP path normalizes before querying; the CLI path passes the user-typed name as-is, so it happened to match.
  • Fix: use LOWER(project) = ? in ProjectExists, Search (FTS and topic-key paths), RecentObservations, and RecentSessions, so mixed-case legacy data matches its normalized equivalent.

Test plan

  • TestSearchLegacyMixedCaseProject (store): seeds legacy mixed-case rows via raw SQL, asserts all four read paths find them with the normalized project name
  • TestHandleSearchLegacyMixedCaseProject (mcp): full handleSearch end-to-end with legacy data, no unknown_project error, results returned
  • go test ./... && go vet ./... && go build ./... clean

Closes #146

… data

SQLite text comparisons are case-sensitive by default. Observations saved
by pre-normalization versions of engram (e.g. project "Ebook2Audio") cannot
be found when queried with the current normalized lowercase name ("ebook2audio")
because WHERE project = ? does not match.

Change ProjectExists, Search (FTS + topic-key paths), RecentObservations,
and RecentSessions to use LOWER(project) = ? so that legacy mixed-case
project names are matched by their normalized equivalents.

Also expose Store.DB() for integration tests that need to inject raw rows
without going through the normalizing public API.

Closes #146
Copilot AI review requested due to automatic review settings May 27, 2026 15:11
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label May 27, 2026
@Alan-TheGentleman Alan-TheGentleman merged commit 69a26c8 into main May 27, 2026
8 of 9 checks passed
@Alan-TheGentleman Alan-TheGentleman deleted the fix/mcp-search-empty-results branch May 27, 2026 15:14
@Alan-TheGentleman Alan-TheGentleman review requested due to automatic review settings May 27, 2026 15:36
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.

MCP server search returns empty results while CLI works correctly (data exists in database)

1 participant