Memex

io.github.STiFLeR7由 GitHub 帳號 STiFLeR7 發布v1.0.3更新於 Oct 26, 2026

Temporal engineering context for agents via MCP.

概覽

AI 產生的概覽

本機 MCP 伺服器,為程式碼倉庫建立雙時態 Neo4j 知識圖譜,並向編碼代理提供工程脈絡、決策與問題紀錄。

可以做什麼
  • 讀取倉庫脈絡:專案簡報、符號呼叫與被呼叫關係、近期決策、未解決問題、過期事實、混合檢索
  • 解釋與預測:依提交差異提供有依據的說明,依檔案路徑回傳受影響模組的排序預測
  • 記錄與維護知識:記錄決策並支援佐證或取代語意,記錄與解決問題,使失效事實作廢
  • 透過 Claude Code 與 Codex 鉤子讓工作階段脈絡保持最新:工作階段起始的工作集、編輯前檢查、恢復時的變更提示、各工作樹獨立檢視
  • 提供權杖節省與驗證統計,並以圖譜投影支撐 Anthropic 原生記憶工具
適用情境
適合持續數週至數月、架構決策不斷累積,且多位代理或開發者共用同一程式碼庫的專案。一次性腳本、臨時原型,或小到可直接貼進提示词的專案則不太必要。
執行需求
以本機程序執行,可透過 npm(stifler-memex-mcp)或 PyPI(memex-mcp,uvx)安裝,需要 Node.js 或 Python 及 uv/pip。需要自備 Neo4j 5 伺服器,並設定 NEO4J_URI、NEO4J_USER、NEO4J_PASSWORD,以及用於實體抽取的 GEMINI_API_KEY。僅限桌面端;首次啟動會下載 Python 相依套件,可能超出用戶端的連線逾時。
安裝前請注意
需要兩個密鑰:GEMINI_API_KEY 與 NEO4J_PASSWORD。倉庫提交與差異會傳送至 Google Gemini 進行合成,這是唯一的外部呼叫。寫入類工具會新增與修改圖譜事實,鉤子會改動程式碼庫的專案設定。遙測資料保存在本機 SQLite 資料庫中。團隊部署預設開啟驗證,需謹慎處理管理員密鑰。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Memex,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

memex: trusted engineering context for agentic software engineering

Open-source MCP server and hook service that keeps Claude Code and Codex engineering context current as the code changes, and holds edits whose evidence changed.

memex.stifler.in

A daemon, hook service and MCP server that turn commits and file changes into structured engineering knowledge and deliver it to agents with freshness and provenance preserved, without making memex a source of personal memory or raw session state.

memex builds a bitemporal knowledge graph of your repository (modules, symbols, decisions, problems, evidence, and code evolution). In v1 it also hooks into Claude Code and Codex: each session starts with the right context, each edit is checked against the current code, and the agent is told exactly what changed.

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

[Memex on AI Agents Listing]

Where memex lives

Websitememex.stifler.in
Sourcegithub.com/STiFLeR7/memex
Python packagememex-mcp on PyPI
Node packagestifler-memex-mcp on npm
MCP Registryregistry.modelcontextprotocol.io, listed as io.github.STiFLeR7/memex
Claude Code pluginSTiFLeR7/claude-plugins
DirectoriesGlama · AI Agents Listing

Evaluation record in BENCHMARK.md, release history in CHANGELOG.md, reporting process in SECURITY.md, and how to work on it in CONTRIBUTING.md.

https://github.com/user-attachments/assets/b14e3185-ea36-4ae5-bd18-2d34e6bf7be4

memex v1 in 60 seconds. If the player does not load, download the video.

Live context (v1)

Coding agents work from a snapshot of the code. A teammate pushes, another agent edits a file, a branch moves, and the agent keeps acting on what it read earlier. v1 keeps that snapshot current, inside Claude Code and Codex:

WhenWhat memex does
Session startDelivers a bounded working set for the task, and confirms delivery from the client's own session record
Before each editChecks whether the context the edit rests on still holds. If not, the edit is held, the agent gets a scoped correction, and it revises
On resumeIf the code changed while the session was away, names the files to re-read
Parallel agentsGives each linked worktree its own view, so agents side by side each see their own code
Trying it outmemex v1 mode shadow records what would be corrected without changing anything; hooks fail open; memex v1 rollback stops memex at once
bash
uv tool install memex-mcp          # installs the `memex` commandcd your-repomemex v1 doctor                    # what is set up, what is missing, what to do nextmemex v1 install claude            # hooks in .claude/settings.json; global settings untouchedmemex v1 install codex --neo4j-uri bolt://localhost:7687   # optional, for Codex

memex needs a Neo4j 5 server you already run (Docker is not required). Hooks go only into the checkout's own project configuration, and memex never asks for or stores your client credentials. Full guide, host recipes and rollback: docs/v1/25_ONBOARDING.md.

mermaid
flowchart LR    A[Your repository<br/>files + git] --> B[memex watcher<br/>tree-sitter + Gemini]    B --> C[Neo4j graph<br/>bitemporal facts]    C --> D[memex core<br/>ContextPacket selection]    D --> H[Hook service<br/>session start · edit checks · resume notice]    D --> E[Hermes MemoryProvider<br/>automatic read-only prefetch]    D --> F[MCP tools<br/>explicit lookup]    H --> G[Claude Code / Codex]    E --> G    F --> G
    style B fill:#cfe8ff,stroke:#0066cc,color:#000    style C fill:#fff4cf,stroke:#cc9900,color:#000    style H 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.

The first start after installing or upgrading downloads memex's Python dependencies (about 40 seconds), which can exceed Claude Code's MCP connect timeout once. Warm it up first, then restart:

bash
npx -y stifler-memex-mcp --help     # one-time download; later starts take a few seconds

If Claude Code still shows a connection timeout, open /mcp and reconnect memex. If a tool says memex cannot reach Neo4j, start Neo4j (for example docker start memex-neo4j); the tools recover without a restart.

Manual

bash
docker compose -f docker/docker-compose.yml up -dcat > .env <<EOFNEO4J_URI=bolt://localhost:7687NEO4J_USER=neo4jNEO4J_PASSWORD=memex-localGEMINI_API_KEY=your-key-hereEOFnpx stifler-memex-mcp init --repo .npx stifler-memex-mcp watch --repo .npx stifler-memex-mcp serve --repo .

Hermes integration

The Hermes integration is read-only. Hermes retains personal memory, raw session state, and execution state. memex supplies repository engineering context through a bounded ContextPacket; it does not ingest Hermes state.db, transcripts, prompts, or tool results.

Add the memex provider to Hermes' profile configuration:

yaml
memory:  provider: memexplugins:  memex:    repo_path: /absolute/path/to/repository    prefetch_timeout_seconds: 7    max_items: 8    max_chars: 12000

If Hermes is not installed, use the same context selector through the MCP get_engineering_context tool. Both paths share the protocol-neutral memex core and fail open when retrieval is unavailable.

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

Self-hosted team deployment

For a shared team setup (one Neo4j + one memex-server, auth on by default, Neo4j's ports never exposed to the host):

bash
bash docker/bootstrap-team-env.shdocker compose -f docker/docker-compose.team.yml up -d

See docker/TEAM-DEPLOY.md for the full flow, capturing the initial admin key, and the down -v footgun to avoid.

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
ContextBounded, ranked, provenance-aware ContextPacket
Live context (v1)Session-start working set, edit checks with scoped corrections, resume change notice, per-worktree views (Claude Code and Codex hooks)
IntegrationsHermes MemoryProvider, MCP resources/tools, Claude Code, Cursor, Codex, Gemini CLI
Failure modeFail-open; agent execution continues without memex
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
Goal 10 evidence8/8 valid paired runs, 0 treatment failures, 0 treatment regressions

The lifecycle

mermaid
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.

mermaid
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, where any assignment can be locked
Context budgetget_project_context stays under 1500 tokens whether your repo has 50 or 5000 modules

Measure Your Savings

memex tracks token reduction metrics and human review actions locally in a SQLite database (~/.config/memex/telemetry.db).

You can query your savings at any time using the CLI:

bash
memex stats

Or view the raw JSON payload:

bash
memex stats --json

Or target a specific repository scope:

bash
memex stats --repo /path/to/repo

This returns an aggregation of:

  • Period Summaries: Calls, tokens returned, naive tokens (size of files requested), tokens saved, and token reduction percentage across today, last 7 days, last 30 days, and lifetime.
  • Top Tools: The most valuable tools sorted by total tokens saved.
  • Agent Clients: Active agents (Claude Code, Gemini CLI, Cursor, Codex) and their token saving distribution.
  • Validation Health: Total validated, unvalidated, and corroborated nodes, along with the elapsed days since the last review.

The same statistics are exposed via the HTTP MCP transport:

http
GET /stats?repo=/path/to/repoAuthorization: Bearer <your-key>

Connect your agent

Claude Code

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

json
{  "mcpServers": {    "memex": {      "type": "stdio",      "command": "npx",      "args": ["-y", "stifler-memex-mcp", "serve", "--repo", "."]    }  }}
Cursor

Add to ~/.cursor/mcp.json:

json
{  "mcpServers": {    "memex": {      "command": "npx",      "args": ["-y", "stifler-memex-mcp", "serve", "--repo", "."]    }  }}
Gemini CLI

Add to ~/.gemini/settings.json:

json
{  "mcpServers": {    "memex": {      "command": "npx",      "args": ["-y", "stifler-memex-mcp", "serve", "--repo", "."]    }  }}
Codex

Add to ~/.codex/config.toml:

toml
[mcp_servers.memex]command = "npx"args = ["-y", "stifler-memex-mcp", "serve", "--repo", "."]
Anthropic memory tool (memory_20250818)

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

bash
memex memory-tool serve --repo .                     # in-processmemex memory-tool serve --repo . --transport http    # FastAPI on :7464
python
from memex.memory_tool import MemexAsyncMemoryToolmemory_tool = MemexAsyncMemoryTool(repo_root=".")client.beta.messages.run_tools(..., tools=[memory_tool])

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/      Anthropic memory_20250818 adapter│   ├── watcher/          daemon + git hooks│   └── cli.py            init / watch / serve / review / graph / cluster├── tests/                unit, integration, and objective evaluation suites├── docker/               Neo4j compose├── npm/                  npx wrapper (publishes as stifler-memex-mcp)└── Dockerfile            introspection-only image for MCP directory sandboxes

Commands

CommandWhat it does
memex initExtract baseline graph state, run first cluster pass
memex watchDaemon that listens for file + git events and writes to Neo4j
memex serveRun the MCP server (stdio, HTTP, or both)
memex reviewTUI that walks lowest-confidence decisions for human validation
memex graph --output graph.htmlSelf-contained D3 force layout with cluster overlays
memex cluster [--rerun] [--dry-run]Run Leiden over the hybrid edge graph; pin cluster IDs by Jaccard ≥ 0.5
memex memory-tool serveBack Anthropic's memory_20250818 tool with a graph projection
memex stats [--json] [--repo <path>]Show context token savings and telemetry stats

License

MIT. See LICENSE.

Author

Hill Patel (@STiFLeR7)

Core Contributors & Maintainers

  • Hill Patel (@STiFLeR7), architect and maintainer
  • Nirvaan Lagishetty (@Nirvaan05), lead contributor and maintainer

Contributing

Open an issue or PR. uv sync --all-extras installs the development toolchain. Run uv run pytest -m "not integration" for the offline suite and uv run ruff check . before opening a PR. Version bumps must update pyproject.toml, npm/package.json, server.json, and the team Docker image tag together.

Release history is in CHANGELOG.md. The v1 design and evaluation records are under docs/v1/, and the v0.9 architecture under docs/architecture/v0.9/.

Vannevar Bush, 1945: "Consider a future device for individual use, which is a sort of mechanized private file and library. It needs a name, and to coin one at random, memex will do."

來源:README.md,提交 62d1f88

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:伺服器未能啟動。

版本歷史

4
  1. v1.0.3最新Oct 26, 2026
  2. v1.0.2Oct 8, 2026
  3. v1.0.1Oct 6, 2026
  4. v0.9.0Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分