Statecore Mcp

io.github.yul761由 GitHub 帳號 yul761 發布v0.1.2更新於 Oct 24, 2026

Auditable memory for coding agents: evidence chains, supersession history, keyless embedded SQLite

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

為編碼代理提供可稽核的長期記憶儲存,每筆事實都保留其證據、版本鏈,以及被丟棄時記錄的原因。

可以做什麼
StateCore 是面向編碼代理的自架記憶執行環境,透過 MCP 以 statecore-mcp 套件提供。它把事件與文件寫入依作用域劃分的記憶,經確定性摘要管線合併為受保護的穩定狀態,並在呼叫端宣告的字元預算內檢索有依據的證據。remember、why、recall、handoff 等工具讓助理記錄決策、追問某筆事實的依據及先前的說法,並把工作階段脈絡交接給同一專案上的其他 MCP 用戶端。被取代與退役的事實仍留在紀錄中,不會被刪除。
適用情境
當助理需要跨工作階段、跨廠商的持久專案記憶,且要求儲存的事實可稽核、可追溯證據、可解釋而非被靜默覆寫時,適合使用。它面向長期在同一程式碼倉庫上工作的編碼代理,包括 Claude Code、Codex、Cursor 等 MCP 用戶端之間的交棒。
執行需求
以 stdio MCP 程序在本機執行,通常透過 npx statecore-mcp 啟動,使用本機 SQLite 檔案;核心記憶、稽核與召回不需要註冊或模型金鑰。選用的對話事件背景蒸餾需要設定 FEATURE_LLM=true,並提供面向 OpenAI 相容端點的 MODEL_API_KEY、MODEL_BASE_URL 與 MODEL_NAME。STATECORE_SCOPE 可覆寫記憶作用域名稱。僅支援桌面端,無網頁版。
安裝前請注意
選用的蒸餾功能會把對話事件傳送到所設定的 OpenAI 相容模型端點,安裝前應確認哪些資料離開本機以及由哪家服務商接收。MODEL_API_KEY 屬於機密,應透過環境變數提供,不要提交到版本庫。記憶寫入、摘要與交棒會改變已儲存狀態,且退役的事實仍保留在稽核鏈上,不會被抹除。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

StateCore

[CI] [Integration Smoke] [License: MIT]

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:

bash
claude mcp add statecore -- npx -y statecore-mcp     # Claude Code

[statecore-mcp demo: remember, facts, why, forget — all keyless]

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.

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 supersededBy chain; 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 its mode from what actually ran, not from what was configured.
  • Everything is checkable. why returns 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.degraded instead of silently downgrading quality
  • Reminders — 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

bash
pnpm install

2. Configure environment

bash
cp .env.example .env

Minimum required variables:

PORT=3002LOCAL_USER_TOKEN=local-dev-userDATABASE_URL=postgresql://postgres:postgres@localhost:5434/statecoreREDIS_URL=redis://localhost:6380

To enable LLM features (digest, answers):

FEATURE_LLM=trueMODEL_PROVIDER=openai-compatibleMODEL_API_KEY=<your-key>MODEL_BASE_URL=https://api.openai.com/v1MODEL_NAME=gpt-5-mini

On OpenAI, pick a model that accepts reasoning_effort. The runtime turn sends it on every request — assistant-runtime.ts defaults it to low rather than leaving it unset — so POST /v1/memory/runtime/turn fails against a gpt-4o* model, which rejects the parameter. Digest and answers do not send it unless MODEL_STRUCTURED_OUTPUT_REASONING_EFFORT is set, so a gpt-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

bash
docker compose -f docker-compose.local.yml up -d

This starts Postgres (with pgvector) and Redis.

4. Prepare the database

bash
pnpm db:generatepnpm db:migratepnpm seed

5. Start the services

bash
pnpm dev:api      # NestJS API on PORT (default 3002)pnpm dev:worker   # background digest + reminder workers

The 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-user

Public surface (/v1)

The /v1 prefix exposes the stable, public-facing subset of the API. Full OpenAPI schema:

GET /openapi.json

Interactive Scalar UI:

http://localhost:3002/docs

Reference documentation: docs/api.md

Key endpoints

MethodPathDescription
POST/v1/memory/eventsIngest a stream event or document
POST/v1/memory/retrieveRetrieve grounded evidence for a query, within an optional maxChars budget
POST/v1/memory/digestTrigger a State Layer digest job
GET/v1/memory/factsGrouped memory facts for a scope
GET/v1/memory/facts/:factId/provenanceA fact's evidence and its full version chain
GET/v1/memory/digests/:digestId/selectionWhat a digest kept, and what it discarded and why
GET/v1/facet-packThe active facet ontology for a scope or account
GET/v1/scopesList scopes
GET/memory/stable-stateCurrent stable-state snapshot ¹
GET/memory/working-stateCurrent working-memory snapshot ¹
GET/memory/layer-statusAggregated 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 /v1 contract 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, currently 1.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:

[statecore-mcp demo: remember, facts, why, forget — all keyless]

bash
npx -y statecore-mcp --data ~/.statecore

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

ClientSetup
Claude Codeclaude mcp add statecore -- npx -y statecore-mcp (config)
dshpinned-executable overlay config included (config)
Cursor.cursor/mcp.json config included (config)
Codex CLI, Gemini CLI, Windsurf, Zed, Cline, OpenCode, Claude Desktop, VS Code Copilotstandard MCP stdio config — npx -y statecore-mcp as the command
Anything else that speaks MCPsame stdio command; HTTP via --url against a deployment

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, diagnosticsapps/worker     BullMQ background workers — digest, working-memory updates, remindersapps/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/Opackages/db         Prisma schema, migrations, and clientpackages/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:

bash
pnpm --filter @statecore/core testpnpm --filter @statecore/api test

Run the full latency + memory quality benchmark:

bash
pnpm benchmark

Run the synthetic regression suite (no LLM required):

bash
pnpm --filter @statecore/core eval

The 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):

system4,000 tok16,000 tok64,000 tok
StateCore51.0% ±7.080.9% ±5.587.6% ±4.6
mem0 OSS61.3% ±6.959.8% ±6.961.3% ±6.9
No memory (recency window)9.3% ±4.122.7% ±5.953.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 contributors
  • docs/repo-map.md — repo structure, where code belongs, and the full doc index
  • docs/philosophy.md — what the engine is for, and why auditability is the centre
  • docs/why-auditable.md — audit mechanisms compared with other memory systems, factually
  • docs/prior-art-failure-modes.md — the documented failure modes this design answers, with verified issue citations
  • docs/glossary.md — facet, pack, supersession, retirement, drop log
  • docs/api.md — full API reference and the /v1 contract rules
  • docs/vision-and-roadmap.md — positioning and roadmap, with a status map
  • docs/technical-overview.md — architecture internals
  • docs/digest-state.md — digest state specification
  • docs/protected-state-merge.md — the deterministic merge, field by field
  • docs/drift-definition.md — drift definition and metrics
  • docs/assistant-runtime.md — assistant runtime specification
  • docs/benchmarking.md — benchmark methodology
  • docs/longmemeval.md — LongMemEval results vs mem0 OSS
  • docs/evaluation-metrics.md — evaluation metrics specification

Contributing

  1. Fork the repo and create a feature branch.
  2. Run pnpm lint and pnpm --filter @statecore/core test before opening a PR.
  3. Follow Conventional Commits.

License

MIT — see LICENSE.

來源:README.md,提交 724f309

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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