Back to MCP Servers

Memex

Developer context continuity system. Watches your git repos and builds a temporal knowledge graph of modules, symbols, decisions, and open problems via Graphiti + Neo4j, then serves it to any AI coding agent over MCP. Every edge carries a validity window and a confidence score t…

knowledge-memoryaiagent
By STiFLeR7
11Updated 1 day agoPythonMIT

Installation

npx -y stifler-memex-mcp

Configuration

{
  "mcpServers": {
    "memex": {
      "command": "npx",
      "args": ["-y", "memex"]
    }
  }
}

How to use

  1. Run the installation command above (if needed)
  2. Open your Claude Code settings file (~/.claude/settings.json)
  3. Add the configuration to the mcpServers section
  4. Restart Claude Code to apply changes

memex — temporal knowledge graph memory for AI coding agents

<!-- mcp-name: io.github.stifler7/memex -->

Persistent memory and codebase context for AI coding agents, served over MCP. A bitemporal knowledge graph of your repository — modules, symbols, decisions, problems — for Claude Code, Cursor, Codex, Gemini CLI, and any MCP-compatible agent.

A daemon and MCP server that turns every commit and every file change into structured graph state: modules, symbols, decisions, problems, lockfile facts. Sessions stop starting blind. Agents stop re-discovering the same refactor every time you /clear.

PyPI PyPI downloads npm npm downloads Claude Code marketplace memex MCP server GitHub stars Tests CodeQL OpenSSF Scorecard License: MIT

memex — temporal knowledge graph MCP server for AI coding agents, built on Graphiti and Neo4j

flowchart LR
    A[Your repository<br/>files + git] --> B[memex watcher<br/>tree-sitter + Gemini]
    B --> C[Neo4j graph<br/>bitemporal facts]
    C --> D[MCP server<br/>stdio / HTTP]
    D --> E[AI agent<br/>Claude · Cursor · Codex · Gemini CLI]
    E -.->|writes decisions back| C

    style B fill:#cfe8ff,stroke:#0066cc,color:#000
    style C fill:#fff4cf,stroke:#cc9900,color:#000
    style E fill:#d4f5d4,stroke:#2d8f2d,color:#000

Install

Via Claude Code marketplace

/plugin marketplace add STiFLeR7/claude-plugins
/plugin install memex-mcp@stifler-marketplace

Restart your Claude Code session.

Manual

docker compose -f docker/docker-compose.yml up -d
cat > .env <<EOF
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=memex-local
GEMINI_API_KEY=your-key-here
EOF
npx stifler-memex-mcp init --repo .
npx stifler-memex-mcp watch --repo .
npx stifler-memex-mcp serve --repo .
ChannelCommand
Claude Code marketplace/plugin install memex-mcp@stifler-marketplace
npx (no install)npx stifler-memex-mcp <cmd>
uvuv add memex-mcp
pippip install memex-mcp
sourcegit clone github.com/STiFLeR7/memex && uv sync

At a glance

PropertyValue
OutputA Neo4j graph populated continuously from your repo
StorageNeo4j via Graphiti. Bitemporal — every edge has created_at and optional expired_at
Survives/clear, terminal crashes, machine restarts, teammate handoffs
Hands off toClaude Code, Cursor, Codex, Gemini CLI, any MCP client
GranularityScales from 50 to 5000+ modules via hierarchical Leiden clusters
SynthesisGemini Flash distills commits into Decision nodes; Pro for grounded synthesis
ConfidenceComputed at query time. Two-regime decay (validated half-life ~139d, unvalidated stale at 30d)
Write governancePer-node-type ACL, intent-confirmation on agent writes, explicit corroborates / supersedes semantics
Tests333 passing, ~93% coverage

The lifecycle

flowchart TD
    Init[memex init<br/>extract baseline] --> Watch[memex watch<br/>daemon + git hooks]
    Watch -->|commit| Extract[tree-sitter extract<br/>symbols, imports, lockfile]
    Extract --> Synth[Gemini Flash<br/>diff → Decision nodes]
    Synth --> Write[Graphiti add_episode<br/>+ post-hoc bitemporal SET]
    Write --> Decay[Scheduler<br/>nightly confidence decay]
    Decay -->|stale edges| Archive[expired_at = now]

    Serve[memex serve<br/>MCP stdio/HTTP] -.->|reads| Write
    Agent[AI agent] -->|14 MCP tools| Serve
    Serve -->|record_decision / record_problem| Write

    Cluster[memex cluster<br/>Leiden over hybrid edges] -.->|every N commits| Write

    style Init fill:#e8f4ff,color:#000
    style Watch fill:#fff4cf,color:#000
    style Synth fill:#ffe0cc,color:#000
    style Serve fill:#d4f5d4,color:#000

MCP tools

14 tools — eight read, four write, two analytic.

Read

ToolWhen
get_project_contextSession start. Returns a cluster-level briefing under 1500 tokens regardless of repo size
get_symbol_contextBefore editing a function or class. Returns callers, callees, linked decisions
get_recent_decisionsLast N days of architectural decisions, optionally module-scoped
get_open_problemsActive bugs and tech debt, sorted by severity
search_contextHybrid search: semantic × keyword × graph traversal × RRF merge
get_stale_contextEdges whose composite confidence dropped below threshold
explain_changeGiven a commit SHA, cross-references the diff with linked Decision/Problem nodes and asks Gemini Pro for a grounded explanation
predict_impactGiven a file path, returns a ranked list of modules likely affected based on graph coupling (no LLM call)

Write

ToolWhen
record_decisionAfter making a technical choice. Supports corroborates (reinforce) and supersedes (replace)
record_problemWhen discovering a bug or piece of tech debt
resolve_problemWhen a tracked problem is fixed
invalidate_edgeWhen a stored fact is no longer true

Bitemporal confidence

Confidence is not a stored number that mutates. It is computed at query time from base_confidence, validation status, time since last reinforcement, and access count.

flowchart LR
    Edge[Edge created<br/>base_confidence] --> Q{Validated by<br/>a human?}
    Q -->|yes| Slow[Slow regime<br/>half-life ~139d]
    Q -->|no| Fast[Fast regime<br/>stale at exactly 30d]
    Slow --> Score[Composite score<br/>conf × recency × rehearsal]
    Fast --> Score
    Score -->|below floor| Stale[get_stale_context surfaces it]
    Score -->|access| Bump[last_reinforced_at updated]
    Bump --> Score

    style Slow fill:#d4f5d4,color:#000
    style Fast fill:#ffd4d4,color:#000
PropertyValue
Validated half-life~139 days
Unvalidated stale threshold30 days (composite < 0.3)
Recency τ90 days (exponential decay)
Composite formulaconf × recency × (1 + rehearsal_w × log(1 + access_count))
Conflict similarity threshold0.4 (below this + overlapping validity = conflict)
Intent-confirmation threshold0.85 (MCP write similarity check)

Hierarchical clusters

memex cluster runs hierarchical Leiden over a hybrid edge graph:

Edge typeWeight
Directory co-location1.0
Module imports2.0
Symbol callslog(1 + calls)
PropertyValue
Algorithmgraspologic.partition.hierarchical_leiden with fixed seed
NamingTF-IDF top-3 over module docstrings + symbol names, parent-dir fallback
ID pinningJaccard ≥ 0.5 across reruns (cluster names stay stable through renames)
User overrides.memex/clusters.yaml — any assignment can be locked
Context budgetget_project_context stays under 1500 tokens whether your repo has 50 or 5000 modules

Connect your agent

<details> <summary><b>Claude Code</b></summary>

Marketplace install above does this for you. Manual wiring in .claude/settings.json:

{
  "mcpServers": {
    "memex": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "stifler-memex-mcp", "serve", "--repo", "."]
    }
  }
}
</details> <details> <summary><b>Cursor</b></summary>

Add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "memex": {
      "command": "npx",
      "args": ["-y", "stifler-memex-mcp", "serve", "--repo", "."]
    }
  }
}
</details> <details> <summary><b>Gemini CLI</b></summary>

Add to ~/.gemini/settings.json:

{
  "mcpServers": {
    "memex": {
      "command": "npx",
      "args": ["-y", "stifler-memex-mcp", "serve", "--repo", "."]
    }
  }
}
</details> <details> <summary><b>Codex</b></summary>

Add to ~/.codex/config.toml:

[mcp_servers.memex]
command = "npx"
args = ["-y", "stifler-memex-mcp", "serve", "--repo", "."]
</details> <details> <summary><b>Anthropic memory tool (memory_20250818)</b></summary>

memex can back Claude's native memory tool — agents read from a per-session graph projection plus a writable scratch zone.

memex memory-tool serve --repo .                     # in-process
memex memory-tool serve --repo . --transport http    # FastAPI on :7464
from memex.memory_tool import MemexAsyncMemoryTool
memory_tool = MemexAsyncMemoryTool(repo_root=".")
client.beta.messages.run_tools(..., tools=[memory_tool])
</details>

Operating principles

#PrincipleThe bet
1Bitemporal, never destructiveEdges are expired, not deleted. WHERE r.expired_at IS NULL filters live state
2Confidence is computed, not storedMutating a number invites silent drift. Recompute every read
3Two regimes for decayValidated facts decay slowly; unvalidated facts must earn their place by being accessed
4Human in the loopmemex review queues lowest-confidence Decision nodes for explicit validation
5Write governancePer-node-type ACL. Decision.policy = open, Module.policy = locked. Intent-confirmation on similar-content writes
6Tokens are budgetedget_project_context stays under 1500 tokens at any repo size via Leiden clusters
7Synthesis only on commitsThe watcher batches by debounce window. Gemini Flash is not in the hot path of a tool call
8Pro for synthesis, Flash for extractionexplain_change uses Pro because grounding matters. Everything else uses Flash
9Multi-repo awareOne watcher + one MCP server can manage hundreds of repos. --repo switches scope
10Local-firstNeo4j runs in your Docker. Gemini is the only outbound call, and only on commits

When to use memex

Use it whenSkip it when
Multi-week or multi-month projectOne-shot script, throwaway prototype
You work across multiple agents (Claude, Cursor, Codex) and want shared contextYou only ever pair with one agent on one task
Architectural decisions are made over time and need to be rememberedThe whole project fits in a single 200k-token context window
You want to query "what did we decide about X" from any sessionYour repo is already small enough to paste into the prompt
Multiple developers using AI agents on the same codebaseSolo work where you never /clear

Project structure

memex/
├── memex/
│   ├── extractor/        tree-sitter + lockfile parsers
│   ├── graph/            Neo4j writes, confidence, archive, cluster engine
│   ├── synthesizer/      Gemini Flash → Decision nodes
│   ├── mcp_server/       14 MCP tools (read + write + analytic)
│   ├── memory_tool/  

…
View source on GitHub