Skip to main content
Claude Mem provides persistent memory across sessions through 4 MCP tools that follow a token-efficient 3-layer workflow pattern. Instead of fetching all historical data upfront, you progressively narrow from a lightweight index to full details — fetching only what you actually need.

The 3-layer workflow

1

Search — get a compact index

Start with search to get a lightweight table of IDs, titles, dates, and types. Each result costs roughly 50–100 tokens.
Review the index and identify which observation IDs look relevant before fetching anything further.
2

Timeline — get chronological context

Use timeline to understand the narrative arc around interesting results — what was happening before and after a specific observation.
Or let it find the anchor automatically from a query:
3

Get observations — fetch full details

Call get_observations only for the IDs you’ve confirmed are relevant. Always batch multiple IDs in a single call.
Each full observation costs 500–1,000 tokens and includes the complete narrative, facts, files, and concepts.

Why this works

Traditional approach

Fetching 20 observations upfront: 10,000–20,000 tokens, with roughly 10% actually useful.

3-layer approach

Search index + timeline + 3 full observations: ~3,000 tokens, 100% relevant.

Tool reference

__IMPORTANT — workflow documentation

An always-visible reminder of the 3-layer workflow pattern injected into the MCP context. It helps Claude understand how to use the search tools efficiently. You do not need to invoke it directly.

search — search memory index

Search your memory and get a compact index with IDs. Parameters
string
Full-text search query. Supports AND, OR, NOT, phrase searches, and column-specific filters. See FTS5 query syntax below.
number
default:"20"
Maximum number of results to return.
number
default:"0"
Skip the first N results for pagination.
string
Filter by observation type: bugfix, feature, decision, discovery, refactor, or change.
string
Filter by record type: observation, session, or prompt.
string
Filter results to a specific project name.
string
Include only results on or after this date (YYYY-MM-DD).
string
Include only results on or before this date (YYYY-MM-DD).
string
default:"date_desc"
Sort order: date_desc, date_asc, or relevance.
Returns: Compact index table with IDs, titles, dates, and types. Example

timeline — get chronological context

Get a chronological view of observations around a specific point or query. Returns depth_before + 1 + depth_after items interleaved in chronological order. Parameters
number
Observation ID to center the timeline around. Required if query is not provided.
string
Search query to find the anchor automatically. Required if anchor is not provided.
number
default:"3"
Number of observations to include before the anchor. Maximum 20.
number
default:"3"
Number of observations to include after the anchor. Maximum 20.
string
Filter results to a specific project name.
Returns: Chronological list of observations, sessions, and prompts interleaved around the anchor. Examples

get_observations — fetch full details

Fetch complete observation details by ID. Always batch multiple IDs in a single call — one request instead of N individual requests. Parameters
number[]
required
Array of observation IDs to fetch.
string
default:"date_desc"
Sort order: date_desc or date_asc.
number
Maximum number of observations to return.
string
Filter results to a specific project name.
Returns: Complete observation objects with narrative, facts, files read, files modified, and concepts. Example
Always batch IDs into a single get_observations call. Making separate calls per ID wastes tokens and adds latency.

Common use cases

Find what went wrong and how it was fixed.
Review architectural choices and their rationale.
Find when and why a specific file was changed.
Track how a feature evolved from first commit to completion.
Restore context after time away from a project.
Study past refactoring approaches before starting a new one.

FTS5 query syntax

The query parameter uses SQLite FTS5 full-text search syntax.

Boolean operators

Phrase searches

Column-specific searches

Combining operators

Token efficiency guide

Cost estimates

Best practices

  1. Always start with search — survey the index before fetching anything
  2. Use small limits first — start with 3–5 results, increase only if needed
  3. Filter before fetching — use type, dateStart/dateEnd, and project to narrow results
  4. Batch get_observations — always group multiple IDs in a single call
  5. Use timeline strategically — only when understanding narrative context matters

Efficient vs. inefficient patterns

Advanced filtering

Date ranges

Multiple observation types

Make separate searches for each type, then compare results:

Pagination

Result metadata

Every observation returned by get_observations includes:

Troubleshooting

Broaden your query:
Check the database has data:
Try without filters:
Error: Observation IDs not found: [123, 456]Possible causes: the IDs belong to a different project, they were deleted, or there is a typo.
Error: Response exceeds token limitsSwitch to the 3-layer workflow instead of fetching large batches upfront:
  1. Use more specific queries — better precision helps the FTS5 index
  2. Add date range filters to narrow the scope
  3. Specify a project filter when possible
  4. Use smaller limit values

Technical details

The MCP tools are a thin wrapper over the worker HTTP API on localhost:37777. The MCP server translates tool calls into HTTP requests; all business logic, database queries, and Chroma vector search run in the worker service.

Progressive disclosure

The philosophy behind the 3-layer workflow

Claude Desktop

Using memory search from Claude Desktop

Architecture overview

System components and data flow

Database schema

Understanding the observation data structure