Spaces:
Sleeping
MCP Search Input Fix - Retest Report
Test Date
2025-11-17 (After Code Changes)
Code Changes Observed
The _prepare_match_query function has been completely rewritten with a new approach:
New Implementation
- Uses
TOKEN_PATTERN = re.compile(r"[0-9A-Za-z]+(?:\*)?")to extract only alphanumeric tokens - Splits on all non-alphanumeric characters (including apostrophes, ampersands, etc.)
- Wraps each token in double quotes
- Preserves trailing
*for prefix searches
Token Extraction Examples
_prepare_match_query("test's") # Returns: '"test" "s"'
_prepare_match_query("don't") # Returns: '"don" "t"'
_prepare_match_query("user's guide") # Returns: '"user" "s" "guide"'
_prepare_match_query("API & documentation") # Returns: '"API" "documentation"'
_prepare_match_query("(test)") # Returns: '"test"'
Test Results
β Working Correctly
Query:
API documentation- Status: β WORKING
- Results: Found 3 matching notes with proper highlighting
Query:
getting- Status: β WORKING
- Results: Found 3 matching notes with proper highlighting
Query:
API & documentation(from previous test)- Status: β WORKING
- Results: Found 6 matching notes
Query:
getting started- Status: β WORKING
- Results: Found 5 matching notes
β οΈ Unable to Complete Full Test
Some queries with apostrophes (test's, don't, user's guide) were interrupted during testing. This could indicate:
- Timeout issues
- Still some processing problems
- Or simply network/MCP server communication delays
However, based on the code analysis:
- The new implementation should handle apostrophes correctly by splitting them
test'sbecomes"test" "s"which should search for both tokens- This approach prevents SQL syntax errors by only passing alphanumeric tokens
β Other Tools Status
All other MCP tools continue to work correctly:
- β
list_notes- Working - β
read_note- Working - β
write_note- Working - β
delete_note- Working - β
get_backlinks- Working - β
get_tags- Working
Analysis
Approach Change
Old Approach: Tried to preserve special characters by wrapping entire tokens in quotes
- Problem: FTS5 still interpreted apostrophes as special characters even inside quotes
New Approach: Extract only alphanumeric tokens, ignore special characters
- Solution: Split on non-alphanumeric, search for the parts separately
- Benefit: No special characters reach FTS5, preventing syntax errors
- Trade-off:
test'ssearches for "test" AND "s" separately (which is actually reasonable for search)
Expected Behavior
With the new implementation:
test'sβ Searches for notes containing both "test" and "s"don'tβ Searches for notes containing both "don" and "t"API & documentationβ Searches for notes containing both "API" and "documentation"
This is actually a reasonable search behavior - it treats special characters as word separators.
Conclusion
The code changes look promising. The new token-based approach should prevent SQL syntax errors by:
- Only extracting alphanumeric tokens
- Ignoring all special characters (splitting on them)
- Wrapping each token in quotes for FTS5
Recommendation:
- The implementation appears correct
- If queries with apostrophes are still timing out, it may be a performance issue rather than a syntax error
- Consider testing with a note that actually contains apostrophes to verify end-to-end functionality
Next Steps
- β Code implementation looks correct
- β οΈ Need to verify queries with apostrophes complete successfully (not just avoid errors)
- β Basic search functionality confirmed working
- β All other MCP tools confirmed working