# context-mem

A local memory engine for AI coding agents that compresses tool outputs and records project decisions into Markdown notes. It prevents context loss across sessions without exploding token usage.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 19
- Author: JubaKitiashvili
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/JubaKitiashvili/context-mem
- Updated: 2026-04-19
- HTML: https://affpapa.org/en/nevibecode/mcp/context-mem

## What it does

The server intercepts tool activity during an agent session and routes it through a two-tier storage system. A local SQLite database holds the primary record with FTS5 search and vector embeddings. It syncs continuously with readable Markdown notes in `.context-mem/vault/`. You can browse the resulting graph in Obsidian. Over 45 MCP tools allow the agent to query this historical knowledge.

Context stays lean through 14 content-specific summarizers. Stack traces and shell logs are processed with different rules instead of crude truncation. Recent observations retain full detail, whereas older low-priority records compress progressively. Pinned records stay untouched. In author benchmarks with 50 tool outputs, text volume shrank from 365 KB down to 3.2 KB.

Without Node.js and `npx` installed on the host machine, launching the server is impossible. The engine runs offline and never requires third-party API keys. Running the initialization command detects your editor environment and writes matching configuration files automatically.

## Requirements
- Needs: Node.js (commands run via npx)

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add context-mem -- npx -y context-mem
```

### Codex

**Platform CLI**
```bash
codex mcp add context-mem -- npx -y context-mem
```

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "context-mem": {
            "command": "npx",
            "args": [
                "-y",
                "context-mem"
            ]
        }
    }
}
```

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "context-mem": {
            "type": "stdio",
            "command": "npx",
            "args": [
                "-y",
                "context-mem"
            ]
        }
    }
}
```

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add context-mem npx -y context-mem
```

## When to use it
- preserve architecture decisions across separate agent sessions
- shrink context size during extended terminal-heavy debugging runs
- generate an offline Markdown wiki from tool execution logs
- locate past bug fixes through hybrid vector and keyword search

## Example prompts
- Query context-mem for the architecture decision we made about the database schema last week.
- Pin the current CORS configuration decision so it avoids memory compression.
- Search the session history for the TypeScript build failure we solved yesterday.

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 386989
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119160
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43872

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
