# dark-memory-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/Opita-Code/dark-memory-mcp  
**GitHub Stars:** 2  
**npm Downloads (last month):** 1115  
**Views:** 5  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/dark-memory-mcp

## Description
Persistent memory + vibe-loop engine for AI agents. Single Go binary, SQLite-backed, stdio MCP.

## Tools
Capabilities this server exposes over MCP:

- **dark_memory_project_create** — Create a new project (INV-7 tenant primitive). Idempotent on project_id — re-creating an existing project returns the existing row. The 'default' project is seeded on Open and cannot be re-created (returns ErrAlreadyExists).
- **dark_memory_session_start** — Start an operational session. Returns the session_id. Use session_close to terminate.
- **dark_memory_session_resume** — Resume an existing session by session_id. Validates the session exists, sets the active project to match, and returns the session row.
- **dark_memory_session_status** — Return the current state of a session (id, operator, project, status, timestamps). Read-only. Includes closing_soon + seconds_until_close so harnesses can warn before the sweeper closes an idle session.
- **dark_memory_session_close** — Close the active session. Returns the write/run/item summary.
- **dark_memory_session_heartbeat** — Refresh a session's last_heartbeat_at so the sweeper does not auto-close it. Call every ~30s during long reasoning pauses or read-only stretches (>60m between writes would otherwise demote the session to closed_aborted). Returns the new last_heartbeat_at.
- **dark_memory_session_recover** — Detect the most-recent closed_aborted session for an operator within a lookback window (INV-8). Read-only: never creates a session. Returns the candidate + requires_consent=true when found, so the caller can decide to follow up with session_resurrect.
- **dark_memory_session_resurrect** — Resurrect a closed_aborted session (INV-8): creates a new session inheriting the original's constitution binding + active mods. The original stays untouched. Use session_recover first to discover the candidate. Returns the new session_id + inheritance audit.
- **dark_memory_research_topic** — Run a research query against the registered ResearchBackend set. Returns deduplicated, confidence-ranked items.
- **dark_memory_research_recall** — Recall previously stored research items by query, with a token budget. Runs the Atlan 5-bucket economy pipeline.
- **dark_memory_research_resume_thread** — Continue a multi-turn research thread by re-running ResearchTopic with the same thread_id.
- **dark_memory_agent_bootstrap** — Return the markdown content of a dark-agent self-bootstrap resource by surface+target. Surfaces: system_prompt | compatibility_matrix | install_guide (requires target) | companion (requires target) | all. The resource URIs are also exposed via resources/read for harnesses that prefer the standard MCP path.
- **dark_memory_agent_recommend_companions** — Reads the harness's clientInfo and returns a structured list of recommended companion MCPs (dark-research, [FUTURE-MCP-N]). Read-only: never auto-installs. Use this on first connect to learn what the harness should install for full functionality.
- **dark_memory_agent_detect_environment** — Returns what the MCP can infer about the harness's runtime: spec version negotiated, client name/title/version, source of clientInfo (initialize handshake vs _meta per-request), negotiated capabilities (resources/tools/prompts/logging), transport. Use this when debugging harness compatibility or filing an issue.
- **dark_memory_vibe_publish** — Publish an artifact under a spec. Runs the full vibe-flow loop: spec_create + artifact_log + brand_match (optional) + compliance_check (optional) + drift_judge + drift_log. Returns verdict + next_action.
- **dark_memory_vibe_spec** — Create a new spec with structured task validation (unique ids, no cycles, depends_on consistency).
- **dark_memory_pipeline_status** — Return the latest drift report for an artifact_id (or nil if none). Read-only. With DARK_FEDERATION_PEER_DSN configured, also probes the dark-research peer when the local lookup misses.
- **dark_memory_resolve_drift** — Operator gate action on a drift report: accept (artifact correct as-is) or reject (artifact wrong).
- **dark_memory_artifact_context** — Return the context projection of an artifact: id, type, spec, brand, jurisdiction, disclosure, validation status, timestamps. Read-only.
- **dark_memory_spec_context** — Return the context projection of a spec: id, case, constitution id+ver, intent (truncated), task count. Read-only.
- **dark_memory_session_context** — Return the context projection of a session. Read-only.
- **dark_memory_recall** — Scoped recall: returns the assembled atomic frames for the requested scope plus an incremental delta (write_audit rows since since_token). scope=global|project|session.
- **dark_memory_agent_memory_save** — Save an agent memory. Mem0-aligned. Scoped to the active project. By default (bind_session=false) the row survives session close; set bind_session=true to tag the row with the active session. v2.3.0.
- **dark_memory_agent_memory_list** — List agent memories in the active project. v2.3.0: scope default is 'project' (was implicit session); scope=operator now requires the explicit operator parameter; scope=agent is new (Mem0 agent_id).
- **dark_memory_agent_memory_recall** — BM25-ranked search over content+title+tags in the active project's agent_memory. v2.3.0 NEW. Lexical-only (FTS5). Vector search is v2.4.0+. Use this tool instead of re-implementing FTS5 escape in client code.
- **dark_memory_agent_memory_get** — Get an agent memory by id. Cross-project reads return ErrNotFound (INV-7).
- **dark_memory_agent_memory_update** — Update an agent memory's mutable fields (content/title/tags/pinned/expires_at/memory_type). Operator + project + agent_id are immutable.
- **dark_memory_agent_memory_archive** — Soft-delete an agent memory (sets archived_at). Recoverable with list(include_archived=true).
- **dark_memory_agent_memory_delegate** — Prepare a delegation context for a sub-agent spawn (v2.9.3). Registers the subagent binding (C2) and returns a ready-to-inject markdown block — session metadata + curated pinned memories + open todos — that the parent embeds in the sub-agent's task prompt so the sub-agent inherits dark-memory context instead of starting blind. Gated by DARK_MEMORY_V280=1.
- **dark_memory_agent_memory_entities** — Get the extracted entity list for one agent_memory row. v2.9.0-alpha PR-3. Returns {id, entities: [{entity, source, confidence, model}]} or nil entities when the row has none. Read-only.
- **dark_memory_subagent_register** — Register or refresh an active subagent binding. v2.8.0-alpha C2. After this call, the subagent's agent_memory_save writes are tagged with subagent_id (NOT the principal's agent_id) so they never leak into the principal's ContextRecap. Defense-in-depth against arxiv:2605.08460 inheritance attacks. Gated by DARK_MEMORY_V280=1.
- **dark_memory_subagent_unregister** — Clear an active subagent binding. v2.8.0-alpha C2. After this call, subsequent agent_memory_save calls fall through to projects.default_agent_id (or empty). Idempotent: returns ErrNotFound if no binding matches. Gated by DARK_MEMORY_V280=1.
- **dark_memory_mindset_apply** — v2.7.0-alpha: Procedurally compose a subagent system_prompt for the given (vibe_case, task_description) and validate it via LLM-as-judge before returning. Cached in agent_memory (TTL via DARK_MINDSET_CACHE_TTL, default 1h). Composition iterates up to DARK_MINDSET_MAX_ITERATIONS (default 3) if the judge rejects the first attempt. Returns a ready-to-inject system_prompt plus tools_recommended and model_recommended for the harness to spawn the subagent. Use case: the harness spawns the subagent via its Task/Agent tool; dark-memory provides the mindset (role + goal + backstory + constraints).
- **dark_memory_delegate_intent** — Wave 5C: Decide whether an intent is handled inline, delegated to sub-agents, or refused (A1: Memory decides). Runs the DelegationRouter pipeline: DECIDE (deterministic rules per vibe_case + bounded LLM choice) → PLAN (subtask graph with dependency batches) → MIND (mindset_apply per subtask: system_prompt + tools + model) → CURATE (agent_memory_delegate per subtask: curated agent_memory context + C2 subagent binding). Returns ready-to-spawn material: the harness injects each subtask's system_prompt + delegation_context into its own Task() spawn call. Gated by DARK_MEMORY_V280=1.
- **dark_memory_llm_key_add** — Store an LLM provider API key in the OS keyring (Windows Credential Manager / Keychain / Secret Service). Validates the key against the provider's free probe by default. The key value is never returned by any tool.
- **dark_memory_llm_key_list** — List LLM provider key status. NEVER returns the key value — only whether a key exists, its source (keyring/env/none), and validation state.
- **dark_memory_llm_key_remove** — Delete a stored LLM provider key from the OS keyring. If the provider also has an env-var key, that one stays (the env is owned by the harness and cannot be modified here).
- **dark_memory_llm_provider_status** — Return the LLM provider routing view: active provider (last successful judge call), per-provider key/cooldown/health, and the DARK_JUDGE_PROVIDER pin. Read-only, no key values.
- **dark_memory_judge** — Run a single LLM-as-judge verdict on content. Eval types: drift_judge, brand_match, compliance_check, pii_detect, prompt_injection_scan, grounding_check, mindset_compose, mindset_quality, spec_test_alignment, mutation_score_check, test_quality_review, security_coverage, resilience_check, oracle_quality. v2.20.0 T12 (spec 1276): for drift_judge, supply artifact_ref instead of content — the judge resolves the artifact (file/git_sha/url/spec_id/artifact_id) and NLI-anchors the verdict. The Content field is ignored on this branch. For other eval_types, Content remains the canonical input. v2.4.2: brand_match + compliance_check consult prior agent_memory decisions/findings (filtered by resolved agent_id); pass no_enrich=true to opt out. v2.17.0: persona_id selects the evaluation lens; spec_intent is included in the user prompt.
- **dark_memory_consensus** — Run N-shot LLM-as-judge and return modal verdict + confidence interval. N clamped to [1, 7]. v2.4.2: forwards agent_id + no_enrich to all N samples so each gets the same agent-scoped enrichment. v2.17.0: forwards persona_id and spec_intent to all N samples so each uses the same persona. v2.20.0 T09 (spec 1276): for drift_judge, supply artifact_ref to anchor consensus to a resolved artifact (recommended). The Content field is then ignored.
- **dark_memory_judgment_history** — List recent SSD evaluations (judge verdicts) for an eval_type + target. Read-only.
- **dark_memory_judge_list_personas** — List the registered persona registries (compiled defaults + Markdown overrides). Read-only. v2.17.0 (spec 1155).
- **dark_memory_active_policy** — Return the active policy snapshot: constitution id+ver+sha, drift status, active mods, canary presence. Read-only.
- **dark_memory_load_constitution** — Return the full constitution row (label, source, parsed JSON) for the given id+version. Read-only.
- **dark_memory_memory_state** — Return the runtime memory snapshot: driver, schema version, table list, per-table counts, active project, canary presence. Read-only.
- **dark_memory_writes** — List recent write_audit rows (every Save emits one, per INV-1). Read-only.
- **dark_memory_anomalies** — List recent anomaly events from the Error Observatory: severity=fatal clusters + domain=gate refusals (INV-3 canary hits, INV-5 cache mismatches, capability/scope refusals). Read-only. Kind filter: fatal | gate. Empty = both.
- **dark_memory_health_ping** — Return the runtime health snapshot (server identity, DB connectivity, schema version, canary, registry counts, uptime, latency). Read-only, no audit side-effects, safe to call from a liveness probe.
- **dark_memory_error_list** — List error_events backlog rows (durable, classified error clusters). Filters: domain, severity, resolved, session_id, tool_name, since. Newest-first (last_seen_at DESC). Read-only. Pass cross_project=true to list across project boundaries (admin elevation — requires DARK_ERROR_OBS_OPERATOR_OVERRIDE=armed OR the caller's operator id in DARK_ERROR_OBS_ADMIN_OPERATORS).
- **dark_memory_error_get** — Get one error_events cluster by id (Error Observatory). Returns null when the id does not exist in the active project (INV-7 existence-leak parity). Read-only. Pass cross_project=true to look up across project boundaries (admin elevation).
- **dark_memory_error_summary** — Return aggregate Error Observatory metrics: total clusters, unresolved, errors in the last N hours (default 1h), counts by domain + severity, top-5 recurring unresolved clusters. GLOBAL scope (cross-project) so operators see overall health. Read-only.
- **dark_memory_error_resolve** — Mark an error_events cluster as resolved with an operator note (backlog triage). Idempotent: resolving an already-resolved cluster returns ok. Returns ErrNotFound when the id does not exist in the active project (INV-7). Operator-gated (INV-1 audit via WriteContext). Pass cross_project=true to resolve across project boundaries (admin elevation); emits a write_audit row with Actor=error_resolve_cross_project_{admin,override}.
- **dark_memory_admin_migrate** — Run pending schema migrations on the active Store. Returns the migration status before + after.
- **dark_memory_admin_schema_status** — Return the current schema version, applied migrations, and the list of tables in the active Store. Read-only.
- **dark_memory_admin_vacuum** — Run a vacuum on the active Store. SQLite: reclaims space; Postgres: no-op (autovacuum handles GC).
- **dark_memory_vlp_handle_event** — Drive the VLP state machine by applying an event to a session. Returns the new state, turn count, and next-action hint. The single entry point that opencode/claude code/etc. use to drive a vibe-loop-protocol session through its lifecycle (idle → drafting_spec → spec_active → drift_judging → complete/needs_human/aborted).
- **dark_memory_embedder_setup_prompt** — Return the embedder consent prompt (v2.9.1-alpha PR-2.1, row 164 §3). Tool surfaces a structured status (auto | ask) + the verbatim prompt text the harness's LLM should surface to the user when dark-memory boots without a detected provider. Single call per project lifecycle; the choice is persisted to agent_memory so dark-memory never asks again. PR-2.1: response includes Harness + HarnessSource so the LLM can suggest the harness-native rung.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "dark-memory-mcp": {
    "command": "npx",
    "args": ["-y","@opitacode/dark-memory-mcp"]
  }
}
```

## Documentation

## What dark-memory-mcp does

dark-memory-mcp gives MCP clients a local memory and workflow layer for AI agents. It stores agent memories in SQLite and scopes recall to a project, session, or global context. Memories can be saved, listed, searched, updated, archived, and retrieved by ID; the search tool uses BM25 ranking over content, titles, and tags through SQLite FTS5.

Projects and operational sessions provide the tenancy and lifecycle model around that memory. Sessions can be started, resumed, inspected, kept alive with heartbeats, closed, or recovered after an idle timeout. A resurrected session inherits the original constitution binding and active modifications while leaving the closed session unchanged.

The server also implements a vibe-loop for checking work against an explicit promise. An agent creates a structured specification, publishes an artifact, and receives a verdict such as aligned, drift detected, or needs human review. Drift reports can be inspected and accepted or rejected by an operator.

## How it works

The process communicates over stdio using MCP and keeps its primary data in a local SQLite database. A project is selected when work begins, and most session-dependent operations require an active session. Memory rows normally survive session closure; callers can bind a memory to the active session when that lifecycle is desired.

Research tools query registered ResearchBackend implementations, return deduplicated confidence-ranked items, recall stored research within a token budget, and continue a multi-turn thread with the same thread ID. Context projection tools expose concise views of artifacts, specifications, and sessions for agents that need structured state.

Agent bootstrap content can be returned by surface and target, while environment detection reports negotiated protocol details, client identity, capabilities, and transport. Companion recommendations use the connecting client's clientInfo and do not install anything automatically.

## Setup and configuration

The repository supports Go 1.25 or newer when building from source. The npm wrapper supports Node.js 18 or newer and downloads the platform binary on first use, so a client can launch it with:

```json
{
  "mcpServers": {
    "dark-memory": {
      "command": "npx",
      "args": ["-y", "@opitacode/dark-memory-mcp"]
    }
  }
}
```

The same MCP entry can be placed in Claude Desktop's `claude_desktop_config.json`, Claude Code's `.claude.json`, or Cursor's `.cursor/mcp.json`. From source, build the executable with `go build -o bin/dark-mem-mcp ./cmd/dark-mem-mcp`.

After configuration, restart the host if necessary and call the health check to confirm that the database is live and the schema is available. The `DARK_MEMORY_V280=1` setting gates the sub-agent memory delegation tool. `DARK_FEDERATION_PEER_DSN` enables a peer probe for pipeline status when the local lookup has no result.

## Tools and capabilities

- Create idempotent projects and manage session start, resume, status, heartbeat, close, recovery, and resurrection.
- Save and manage project-scoped agent memories, including updates, soft deletion, archived-memory listing, BM25 recall, and entity retrieval.
- Produce scoped context and incremental recall deltas for global, project, or session state.
- Run research queries, recall stored research, and resume research threads.
- Define structured specs, publish artifacts, inspect drift, and accept or reject drift reports.
- Bootstrap agents, recommend companion MCPs, and inspect client negotiation details.

Delegation prepares a markdown context block containing session metadata, selected pinned memories, and open todos for a sub-agent. It is gated by `DARK_MEMORY_V280=1`.

## Limitations and notes

The project is an alpha pre-release and its tool surface and schema may change. SQLite is the production path; PostgreSQL support is not ready for production use. The agent-memory recall operation is lexical BM25/FTS5 search rather than vector search. Most operations require an active session, and memory scope must be considered when a note cannot be found after changing projects or sessions.

Idle sessions can be closed automatically. During long pauses, the caller should send heartbeats roughly every 30 seconds; otherwise a session with an extended period between writes can be demoted to `closed_aborted`. Recovery only identifies a candidate and requires consent before resurrection creates a new session.

The vibe-loop judge records a comparison between an artifact and its specification, but the broader engine is still under development. Operators should review the project's status before relying on it for production workflows.

_Full upstream README: https://allmcps.com/mcp/dark-memory-mcp/readme_

