MCP Search: FTS query syntax errors with special characters #238

Closed
opened 2026-01-25 00:20:59 +00:00 by jack · 0 comments
Owner

Problem

The MCP search tool (mcp__plugin_claude-mem_mcp-search__search) fails with SQL errors for certain query patterns.

Reproduction

1. Wildcard search with *

Query: "*"
Error: unknown special query: 

Full error:

select `o`.* from `observations` as `o` inner join observations_fts fts ON o.id = fts.rowid where observations_fts MATCH '*' order by `o`.`created_at_epoch` desc limit 50 - unknown special query: 

2. Search terms containing hyphens

Query: "claude-mem"
Error: no such column: mem

Full error:

select `o`.* from `observations` as `o` inner join observations_fts fts ON o.id = fts.rowid where observations_fts MATCH 'claude-mem' order by `o`.`created_at_epoch` desc limit 50 - no such column: mem

Expected Behavior

  1. Wildcard searches should either be supported or return a user-friendly error message
  2. Hyphenated terms should be properly escaped/quoted for FTS5 syntax (e.g., "claude-mem" or claude AND mem)

Root Cause

SQLite FTS5 interprets - as a NOT operator and * as a prefix search operator. The search query needs to be sanitized/escaped before being passed to the MATCH clause.

Suggested Fix

In the search endpoint, sanitize the query string:

  • Escape or quote terms containing special FTS5 characters (-, *, ", etc.)
  • Or wrap the entire query in double quotes for literal matching
  • Consider using fts5_fold_diacritics for accent-insensitive search
## Problem The MCP search tool (`mcp__plugin_claude-mem_mcp-search__search`) fails with SQL errors for certain query patterns. ## Reproduction ### 1. Wildcard search with `*` ``` Query: "*" Error: unknown special query: ``` Full error: ``` select `o`.* from `observations` as `o` inner join observations_fts fts ON o.id = fts.rowid where observations_fts MATCH '*' order by `o`.`created_at_epoch` desc limit 50 - unknown special query: ``` ### 2. Search terms containing hyphens ``` Query: "claude-mem" Error: no such column: mem ``` Full error: ``` select `o`.* from `observations` as `o` inner join observations_fts fts ON o.id = fts.rowid where observations_fts MATCH 'claude-mem' order by `o`.`created_at_epoch` desc limit 50 - no such column: mem ``` ## Expected Behavior 1. Wildcard searches should either be supported or return a user-friendly error message 2. Hyphenated terms should be properly escaped/quoted for FTS5 syntax (e.g., `"claude-mem"` or `claude AND mem`) ## Root Cause SQLite FTS5 interprets `-` as a NOT operator and `*` as a prefix search operator. The search query needs to be sanitized/escaped before being passed to the MATCH clause. ## Suggested Fix In the search endpoint, sanitize the query string: - Escape or quote terms containing special FTS5 characters (`-`, `*`, `"`, etc.) - Or wrap the entire query in double quotes for literal matching - Consider using `fts5_fold_diacritics` for accent-insensitive search
jack closed this issue 2026-01-25 00:24:28 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
customable/claude-mem#238
No description provided.