Skip to main content

Overview

Search your persistent memory using natural language or keywords. Powered by SQLite FTS5 full-text search with BM25 ranking, this tool finds past decisions, bugs fixed, patterns used, files changed, and any context from previous coding sessions.
This is a core tool in the agent profile, always loaded in the MCP context.

Parameters

string
required
Search query — natural language or keywordsExamples:
  • "JWT authentication"
  • "N+1 query fix"
  • "FTS5 sanitization"
  • "authentication middleware decision"
The query is automatically sanitized for FTS5:
  • Each term is wrapped in quotes to handle special characters
  • Boolean operators are preserved (AND, OR, NOT)
  • Safe to include user input directly
string
Filter results by observation typeRecognized types:
  • tool_use — automatic captures from agent tool calls
  • file_change — file modifications
  • command — shell commands executed
  • file_read — files read during sessions
  • search — search operations performed
  • manual — manually saved observations
  • decision — architectural or technical decisions
  • architecture — system design, patterns
  • bugfix — bug fixes
  • pattern — conventions, guidelines
Example:
string
Filter results by project nameOnly returns observations associated with the specified project.Example:
string
Filter observations by visibility scopeOptions:
  • project (default) — project-scoped observations
  • personal — cross-project personal knowledge
Example:
number
Maximum number of results to returnDefault: 10Maximum: 20Results are ranked by FTS5 BM25 relevance score.

Response

array
Array of search results, ranked by relevance
Each result includes:
  • ID — observation identifier for mem_get_observation or mem_timeline
  • Type — observation category
  • Title — short summary
  • Content — truncated preview (up to 300 characters)
  • Project — associated project (if any)
  • Scopeproject or personal
  • Created timestamp — when it was saved
Example response:
If no results are found:

Usage Examples

Returns all observations containing “authentication” across all projects and types.

Search by Type

Returns only bugfix observations about N+1 queries.
Returns observations about “middleware” only from the “my-api” project.

Personal Knowledge

Returns up to 5 cross-project observations about error handling.

Multi-Word Query

FTS5 tokenizes the query and ranks results by how many terms match and their relevance.

FTS5 Search Behavior

Tokenization

FTS5 tokenizes both the query and stored content:
  • Case-insensitive — “JWT” matches “jwt” and “Jwt”
  • Stem matching — “running” matches “run”, “runs”, “ran”
  • Special characters — automatically quoted to prevent syntax errors

Ranking (BM25)

Results are ranked by BM25 relevance:
  1. Term frequency — how often the query terms appear
  2. Document length — shorter documents rank higher for the same term frequency
  3. Inverse document frequency — rare terms boost ranking more than common terms

Boolean Operators

FTS5 supports boolean search (advanced):
This finds observations with “JWT” and “authentication” but excludes those containing “session”.
For most use cases, simple natural language queries work best. FTS5 handles the ranking automatically.

When to Use

  • Context recovery — recall what was done in previous sessions
  • Decision lookup — find why an architectural choice was made
  • Bug reference — remember how a similar bug was fixed
  • Pattern discovery — find established conventions
  • File changes — locate where specific changes were made

Progressive Disclosure Pattern

mem_search returns truncated content to save tokens. For full details:
1

Search first

Returns compact results with observation IDs.
2

Get full content (if needed)

Use mem_get_observation to retrieve untruncated content.
3

View timeline (optional)

Use mem_timeline to see chronological context.

Search Performance

  • FTS5 index — full-text search index on title and content columns
  • Sub-millisecond queries — typical search completes in less than 5ms
  • No external dependencies — pure SQLite, no vector database

Empty Results

If mem_search returns no results:
  1. Broaden the query — try fewer or more general terms
  2. Check the project filter — remove project filter to search all projects
  3. Check the type filter — remove type filter to search all categories
  4. Verify scope — try scope: "personal" if searching for cross-project knowledge