← Back to Docs

MCP Tools

Using Memex as an MCP server for AI coding assistants

Memex implements the Model Context Protocol (MCP), allowing AI coding assistants to search your conversation history.

Setup

See Quick Start for MCP configuration commands.

Verify MCP is working:

curl -X POST http://localhost:10013/api/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Tools

search_history

Search conversation history with progressive disclosure.

ParameterTypeRequiredDescription
querystringYesSearch keywords
levelstringNoDetail level: sessions (default), talks, raw
cwdstring | stringNoFilter to specific project(s). Supports exact path, prefix, or glob patterns (e.g. */ETerm*)
exclude_cwdstring | stringNoExclude specific project(s). Supports exact path, prefix, or glob patterns (e.g. *memex*)
timestringNoTime shortcut: 1d, 3d, 1w, 1m
fromstringNoStart date YYYY-MM-DD (mutually exclusive with time)
tostringNoEnd date YYYY-MM-DD (mutually exclusive with time)
limitnumberNoMax results (default: 5)

Level options:

LevelReturnsUse when
sessionsL3 session summariesQuick overview (default)
talksL2 per-prompt summariesNeed more detail
rawL0 original messagesNeed exact content

Project filtering examples:

// Single project (exact match or prefix)
{ "cwd": "/Users/me/projects/myapp" }

// Multiple projects
{ "cwd": ["/Users/me/projects/app1", "/Users/me/projects/app2"] }

// Glob pattern
{ "cwd": "*/ETerm*" }

// Exclude projects
{ "exclude_cwd": "*memex*" }

// Combined: include some, exclude others
{ "cwd": "*/vimo/*", "exclude_cwd": ["*test*", "*archive*"] }

get_session

Get session messages. Two modes available:

Mode 1: Around position - Get context around a specific message

ParameterTypeRequiredDescription
sessionIdstringYesSession ID (full or prefix)
aroundnumberYesPosition from search_history result at field
contextnumberNoMessages before/after (default: 5, max: 20)

Mode 2: Pagination - Browse from start or end

ParameterTypeRequiredDescription
sessionIdstringYesSession ID (full or prefix)
limitnumberNoMessages to return (default: 10)
orderstringNoasc (from start) or desc (from end)

Note: Content truncated when limit > 5.

get_recent_sessions

Get recent sessions, optionally filtered by project.

ParameterTypeRequiredDescription
cwdstring | stringNoFilter to specific project(s). Supports exact path, prefix, or glob patterns
exclude_cwdstring | stringNoExclude specific project(s). Supports exact path, prefix, or glob patterns
limitnumberNoMax results (default: 5)

See search_history for project filtering examples.

list_projects

List all projects with statistics. No parameters.


Typical Workflow

1. search_history "anything you want" → find relevant sessions
2. get_session sessionId=xxx around=42 → get context around match

The at field in search results can be passed directly to get_session's around parameter.


Usage

In your AI CLI:

search my history for "anything you want"

The AI will call search_history and return relevant conversations.