statecore-mcp
StateCore MCP gives coding agents auditable, long-term project memory over the Model Context Protocol.
remember— store durable project/user facts, preferences, decisions, and constraints; notes default to 500 chars, setconsolidate=truefor up to 2000 chars distilled in the background.recall— retrieve relevant memory packed into a character budget, returning the distilled digest, believed facts, recent events, and what was left out.facts— list everything currently believed about the project, grouped with fact IDs and pending distillation count.why— explain why a fact is believed by showing its source evidence and full version chain, including superseded and retired versions.forget— suppress a fact byfactKey; the record is retired, not deleted, preserving the audit chain.handoff— record where a session stopped (summary, open questions, next steps); the next session receives it at the top ofrecall, andclear=trueretires the active handoff.
StateCore
Auditable memory for coding agents and AI systems. Every fact StateCore holds carries its evidence, its version chain, and a recorded reason for every discard — so "why do you believe this, and what did you believe before?" always has an answer.
StateCore is a self-hosted, low-drift long-term memory runtime for local or BYO models. It turns memory from accumulated text into governed state: events are ingested, run through a deterministic digest pipeline, and merged into protected stable state. The LLM proposes; the pipeline decides.
Try it in 30 seconds
No server, no signup, no model key — one SQLite file over MCP:
claude mcp add statecore -- npx -y statecore-mcp # Claude Code
remember a decision in one session, ask why in the next: you get the fact, the evidence behind it, and its version history — superseded and retired facts stay on the record, marked, never deleted. And sessions hand off across vendors: handoff records where one session stopped, and the next one — Claude Code, Codex, Cursor, any MCP client on the same project — receives it at the top of recall, with every earlier stop-point still on the audit chain. Configs for Cursor, dsh, and every other MCP host: apps/mcp/README.md.
Related MCP server: nuzo-memory
Capture is easy. Trust is hard.
Most agent-memory tools compete on capturing more — hook every event, compress the transcript, inject it back. Capture is the solved half of the problem. The unsolved half is what those tools' own issue trackers are full of: memories that silently stop being written, stale decisions injected as if still current, cross-project leakage, and no way to audit or repair what the store believes. That is not a rhetorical claim — docs/prior-art-failure-modes.md cites the verified issues, by number, across five systems.
StateCore is built for that second half:
Nothing is silently lost. Every discard is logged against a fixed set of reasons; every replaced fact keeps a
supersededBychain; retired facts are marked, never deleted.Nothing is silently believed. Writes go through a deterministic pipeline with consistency gates — an LLM proposal alone cannot promote itself into stable state.
Nothing degrades silently. A failed digest carries
degraded; the budget reports what it refused; retrieval reports which embedding stages failed and derives itsmodefrom what actually ran, not from what was configured.Everything is checkable.
whyreturns a fact's evidence and full version history; a digest's selection report shows exactly what it kept and dropped.
How this compares to other memory systems, mechanism by mechanism: docs/why-auditable.md.
Features
Event store — ingest stream events and keyed documents into per-scope memory
Digest pipeline — background worker consolidates events into stable state through selection, merge, consistency checks, and retry
Protected state — goals, constraints, decisions, and todos are gated by a consistency gate; the LLM proposes, the pipeline enforces
Auditable facts — every fact carries its evidence and its supersession chain, and a fact that leaves the active set is retired rather than deleted, so "why do you believe this, and what did you believe before" stays answerable
Recorded discards — the digest logs what it dropped and why, against a fixed set of reasons; losing information is survivable, losing it silently is not
Replaceable ontology — facets come from a pack resolved per tenant and scope, so the engine stores, protects and supersedes without knowing what a facet means
Retrieval — hybrid keyword + optional pgvector semantic search over events and digests, packed into a caller-declared character budget that reports what it refused; pinned events and write-protected facts get a bounded ranking boost (never a filter), and embedding failures are itemised in
retrieval.degradedinstead of silently downgrading qualityReminders — daily reminder job surfaces follow-up items from active scopes
Benchmarks — a published LongMemEval comparison against mem0 OSS at an equal context budget, plus a built-in synthetic regression suite that guards fact retention, goal stability, decision continuity, and retrieval MRR across commits
MCP server —
statecore-mcp, a zero-deploy Model Context Protocol front end for coding agents; keyless by default, one SQLite file, no infrastructure
Quickstart
1. Install dependencies
pnpm install2. Configure environment
cp .env.example .envMinimum required variables:
PORT=3002
LOCAL_USER_TOKEN=local-dev-user
DATABASE_URL=postgresql://postgres:postgres@localhost:5434/statecore
REDIS_URL=redis://localhost:6380To enable LLM features (digest, answers):
FEATURE_LLM=true
MODEL_PROVIDER=openai-compatible
MODEL_API_KEY=<your-key>
MODEL_BASE_URL=https://api.openai.com/v1
MODEL_NAME=gpt-5-miniOn OpenAI, pick a model that accepts
reasoning_effort. The runtime turn sends it on every request —assistant-runtime.tsdefaults it tolowrather than leaving it unset — soPOST /v1/memory/runtime/turnfails against agpt-4o*model, which rejects the parameter. Digest and answers do not send it unlessMODEL_STRUCTURED_OUTPUT_REASONING_EFFORTis set, so agpt-4o*model appears to work right up until the first runtime turn. Any endpoint that accepts the parameter, or ignores unknown ones, is fine.
3. Start infrastructure
docker compose -f docker-compose.local.yml up -dThis starts Postgres (with pgvector) and Redis.
4. Prepare the database
pnpm db:generate
pnpm db:migrate
pnpm seed5. Start the services
pnpm dev:api # NestJS API on PORT (default 3002)
pnpm dev:worker # background digest + reminder workersThe API is available at http://localhost:3002 (or whatever PORT is set to).
API
Authentication
All requests require an x-user-id header. For local development, set LOCAL_USER_TOKEN=local-dev-user in .env and send:
x-user-id: local-dev-userPublic surface (/v1)
The /v1 prefix exposes the stable, public-facing subset of the API. Full OpenAPI schema:
GET /openapi.jsonInteractive Scalar UI:
http://localhost:3002/docsReference documentation: docs/api.md
Key endpoints
Method | Path | Description |
|
| Ingest a stream event or document |
|
| Retrieve grounded evidence for a query, within an optional |
|
| Trigger a State Layer digest job |
|
| Grouped memory facts for a scope |
|
| A fact's evidence and its full version chain |
|
| What a digest kept, and what it discarded and why |
|
| The active facet ontology for a scope or account |
|
| List scopes |
|
| Current stable-state snapshot ¹ |
|
| Current working-memory snapshot ¹ |
|
| Aggregated layer health ¹ |
The three audit readers in the middle are the ones that make the engine's memory
checkable rather than merely stored; docs/api.md lists the full frozen surface.
API stability: the
/v1contract is frozen and additive-only — see STABILITY.md. It currently covers 22 operations across 20 paths. The contract carries its own version in the generated OpenAPI document (info.version, currently1.8.0), which is what tells you how current a spec you are holding; it is not the release tag and not any package version.
¹ Internal read-model endpoints — registered only at /memory/..., not under /v1, and not part of the frozen /v1 contract.
Use it from your coding agent (MCP)
statecore-mcp is a separately published npm package that fronts this engine
over the Model Context Protocol — no
running server required. It runs the engine embedded (one process, one SQLite
file), keylessly by default:

npx -y statecore-mcp --data ~/.statecorePoint any MCP client at it, or run it against a full StateCore deployment via
--url for shared/multi-agent memory. Full docs, host configs, and the
keyless/keyed capability matrix: apps/mcp/README.md.
Client | Setup |
Claude Code |
|
dsh | pinned-executable overlay config included (config) |
Cursor |
|
Codex CLI, Gemini CLI, Windsurf, Zed, Cline, OpenCode, Claude Desktop, VS Code Copilot | standard MCP stdio config — |
Anything else that speaks MCP | same stdio command; HTTP via |
Team memory: one self-hosted deployment as the shared project brain for every agent your team runs — dsh sessions, Claude Code, CI — with one audit trail across all of them: docs/team-memory.md.
Architecture
apps/api NestJS HTTP server — ingestion, retrieval, runtime turns, diagnostics
apps/worker BullMQ background workers — digest, working-memory updates, reminders
apps/mcp statecore-mcp — MCP server, embedded or thin client against apps/api
packages/core Memory engine (MemoryService, DigestService, RetrieveService, AssistantSession)
packages/contracts Zod schemas for all API I/O
packages/db Prisma schema, migrations, and client
packages/prompts LLM prompt templates (digest, answer, runtime)StateCore sits between your client and your model endpoint. Events flow in, the digest pipeline consolidates them into protected state, and retrieval pulls grounded evidence back out for answers or runtime turns.
Three-layer memory model:
Fast Layer — synchronous; assembles prompt context for the current turn from recent events, working memory, and stable state
Working Memory — lightweight, quickly-updated structured memory; bridges raw recent turns and slow stable-state consolidation
State Layer — authoritative, replayable, low-drift long-term memory; updated asynchronously through the digest control pipeline
See docs/vision-and-roadmap.md for the layered model design and roadmap.
Testing and Benchmarks
Run package tests:
pnpm --filter @statecore/core test
pnpm --filter @statecore/api testRun the full latency + memory quality benchmark:
pnpm benchmarkRun the synthetic regression suite (no LLM required):
pnpm --filter @statecore/core evalThe synthetic suite is a regression guard, not a capability benchmark: every scenario scores 1.000 on the current engine, deliberately — its job is to fail when a change breaks retention, stability, or retrieval, not to rank systems. The comparison that ranks systems is LongMemEval, below.
Benchmark methodology: docs/benchmarking.md
LongMemEval
Compared against mem0 OSS on
LongMemEval at an equal context
budget — the same number of characters of memory in the answerer's prompt,
rather than the same number of retrieved items. 194 questions, gpt-5 answering,
the official gpt-4o judge (2026-08-08):
system | 4,000 tok | 16,000 tok | 64,000 tok |
StateCore | 51.0% ±7.0 | 80.9% ±5.5 | 87.6% ±4.6 |
mem0 OSS | 61.3% ±6.9 | 59.8% ±6.9 | 61.3% ±6.9 |
No memory (recency window) | 9.3% ±4.1 | 22.7% ±5.9 | 53.6% ±7.0 |
At 64k, StateCore also beats the 70.1% ±6.4 ceiling of pasting the entire corpus into the prompt with no memory layer at all. At 4k it loses to mem0 by 10 points — a real difference in kind, explained rather than closed, in the full write-up.
Numbers, caveats and what the benchmark does not measure:
docs/longmemeval.md. Harness, raw retrievals and
per-question judge verdicts:
memory-budget-bench.
Documentation
docs/start-here.md— orientation for new contributorsdocs/repo-map.md— repo structure, where code belongs, and the full doc indexdocs/philosophy.md— what the engine is for, and why auditability is the centredocs/why-auditable.md— audit mechanisms compared with other memory systems, factuallydocs/prior-art-failure-modes.md— the documented failure modes this design answers, with verified issue citationsdocs/glossary.md— facet, pack, supersession, retirement, drop logdocs/api.md— full API reference and the/v1contract rulesdocs/vision-and-roadmap.md— positioning and roadmap, with a status mapdocs/technical-overview.md— architecture internalsdocs/digest-state.md— digest state specificationdocs/protected-state-merge.md— the deterministic merge, field by fielddocs/drift-definition.md— drift definition and metricsdocs/assistant-runtime.md— assistant runtime specificationdocs/benchmarking.md— benchmark methodologydocs/longmemeval.md— LongMemEval results vs mem0 OSSdocs/evaluation-metrics.md— evaluation metrics specification
Contributing
Fork the repo and create a feature branch.
Run
pnpm lintandpnpm --filter @statecore/core testbefore opening a PR.Follow Conventional Commits.
License
MIT — see LICENSE.
Available Tools
6 toolsfactsA
List everything currently believed about this project, grouped, with fact ids, plus how many captured events are still waiting for distillation. Use to review or audit the memory.
Inputs: no named parameters.
forgetA
Suppress a fact by factKey. The record is retired, not deleted — the audit chain is preserved.
Inputs: factKey (required).
handoffA
Record where this session stopped — a summary, open questions, and next steps — before ending or compacting. The next session (in this client or any other MCP client) receives it at the top of recall; each handoff supersedes the previous one on an auditable chain (why on the returned handoffId walks it). Pass clear=true to retire the active handoff instead.
Inputs: clear, summary, nextSteps, openQuestions.
recallA
Retrieve project memory relevant to a query, packed into a character budget. Returns the distilled digest, believed facts, recent events, and a budget report of what was left out. Call at the start of a session or before relying on past context.
Inputs: query, maxChars.
rememberA
Store a durable fact about this project or user. Use for preferences, decisions, constraints, and anything worth knowing next session. Deterministic and audit-tracked. Notes (the default path) are capped at 500 characters; pass consolidate=true for longer conversational context, accepted up to 2000 characters and distilled in the background.
Inputs: text (required), consolidate.
whyA
Explain why a fact is believed: its source evidence and the full version chain, including superseded and retired versions. Pass a factId from facts or recall.
Inputs: factId (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool targets a distinct memory lifecycle stage: remember creates, recall/facts read (query vs full audit), forget retires, why explains provenance, and handoff manages session continuity. The only mild ambiguity is facts vs recall, but their descriptions clearly differentiate full audit from query-budgeted retrieval.
All tool names are lowercase single words and mostly imperative verbs (remember, recall, forget, handoff), so the style is consistent and readable. 'facts' and 'why' are noun/question-word deviations rather than verb forms, but they are not mixed conventions.
Six tools is well-scoped for a project-memory server: storage, retrieval, audit, forgetting, provenance, and session handoff each get one slot without redundancy. The count feels neither thin nor heavy.
The core memory lifecycle is covered: create (remember), read (recall/facts), delete (forget), provenance (why), and session handoff. The main gap is no explicit fact-update tool, though supersession/versioning is hinted at and forget+remember provides a workaround.
Maintenance
Related MCP Connectors
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Provenance-carrying memory for AI agents: corrections supersede, never overwrite. Free, API + MCP.
Persistent memory for AI agents, for code, research and everyday life. Stale facts retire.
Long-term memory for AI coding agents: durable project facts, recalled by every MCP client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceLocal, cross-agent memory for AI coding agents using a single SQLite file, enabling persistent sessions and durable facts shared across multiple MCP-compatible tools.8 npmMIT
- AlicenseNot gradedqualityFmaintenanceLocal-first, auditable memory for AI agents. Provides durable context for MCP hosts with SQLite storage, CLI, and MCP tools for memory management.2Apache 2.0
- AlicenseAqualityBmaintenancePersistent memory for AI coding agents, storing decisions, bug fixes, conventions, and discoveries in a local SQLite database and automatically recalling them when relevant. Works with Claude Code, Codex, Cursor, Gemini CLI, and other MCP-compatible agents.224MIT
- AlicenseCqualityBmaintenanceLocal-first, governable long-term memory for AI agents. Provides SQLite-backed storage, cross-session recall, and traceable memory corrections through a standard MCP interface.4026 PyPI1MIT