artek-brain
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
artek-brain
Shared, versioned memory for people and AI coding agents. One instance per project.
Agents (Claude Code, opencode, Cursor) lose context between sessions and overwrite each other's notes. artek-brain gives them one place to read and write project knowledge through MCP, CLI or HTTP, with every change versioned, attributed and reversible. There are no LLM calls inside the memory layer: reads and writes are deterministic.
Русская версия · Specification (RU)
What it does
Versioned documents. Markdown with frontmatter. Every write is a new version with author, reason, sha256 and diff. Roll back a document, a version, one author's edits over a period, or a bad batch.
Explicit conflicts. Writes carry
base_version; on mismatch the write is refused with the current version number, the conflicting sections and a diff. Edits to different sections merge, edits to the same section conflict.Access control. Read, write and admin rights by path prefix; scoped agent tokens with TTL and revocation. Agents cannot change
rules/,owner/or approved documents; they leave proposals inowner/inboxfor a human to approve.Secret scanning. Writes containing keys, tokens or PEM blocks are rejected; secrets are stripped from logs.
Search and navigation. SQLite FTS5 (BM25) with filters, outlines with section sizes, reads by section or token budget, links and backlinks, "what changed since my last visit".
Audit and metrics. Every action is logged, searches included: who, what, when, why, from which session and client (MCP sessions from Claude Code and opencode are labelled automatically).
Cheap storage. Metadata in SQLite (WAL), content in hash-addressed blobs with dedup and compression, quotas, garbage collection, backups with sha256 manifests.
Knowledge aging. Every document has a freshness deadline: explicit
review_byin frontmatter, or a TTL per folder fromsettings.json(backlog.md7 days,docs/30,notes/90 by default). The brief andbrain quality reportflag overdue documents and "docs behind notes": reference docs that were not updated while new notes piled up after them.Agent brief and hook.
brain_op(action="brief")returns a short (2000 chars by default) start-of-work digest: anchors, what to double-check before relying on it, recent changes, inbox.brain setupinstalls a Claude CodeSessionStarthook, so the brief is injected on start and again after context compaction.
Related MCP server: clewwiki
How it fits together
flowchart LR
CC[Claude Code sessions<br/>and subagents] -- MCP --> S[brain mcp]
OC[opencode agents] -- MCP --> S
H[human / scripts] -- CLI / HTTP --> S
S --> SV[Service: access, secrets, quotas]
SV --> ST[(SQLite WAL:<br/>versions, audit)]
SV --> B[(blobs by sha256:<br/>dedup, zlib, deltas)]
SV --> F[(FTS5 index)]
SV --> Q[quality: aging, drift,<br/>dups, contradictions]
HK[SessionStart hook] -- brain hook --> CCLessons from real use
The memory has been the working memory of a production project (a cash-desk web app plus a Chrome extension, built almost entirely by agents) since November 2026. An audit after the first week of ~40 sessions, 9 parallel worktree sessions and 50+ subagents showed:
It works where it matters: an owner decision written by one session ("hold changes for the big release") stopped a different session from deploying three hours later; a concurrent edit of the backlog was caught by
base_versionand merged without loss; a secret in a note was rejected and rephrased within seconds.What went wrong was not storage but upkeep: reference docs were filled once and never updated, while 50+ notes piled up. A typical fact ("prod is on version X", "server Y") stayed true for 3–5 days. Agents that read memory first got a stale picture.
Agents read memory only when told to: worktree sessions and subagents ignored it unless the prompt named it; after context compaction the agent recovered from files on disk, not from memory. Multi-word searches returned nothing in half the cases, and two out of three truncated reads were never continued.
Version 0.2 addresses exactly these: TTL-based aging, the "docs behind notes" detector, a brief with a "check before relying" block, a compaction hook, any-word search fallback, line-based truncation with the list of unread sections, and per-session/client attribution in the audit log.
Quick start
uv tool install --from git+https://github.com/itsuppartem/artek-brain "artek-brain[mcp]"
cd /path/to/project && brain setup --name "My project"brain setup creates .brain/ (git-ignored; every *.sqlite3, owner.token and agent.token get mode 600, blobs/ mode 700), .mcp.json for Claude Code, opencode.json for opencode agents (each tagged with its own BRAIN_CLIENT for the audit log), a rules block in AGENTS.md and a SessionStart hook in .claude/settings.json (skipped if the hook is already in your user-level ~/.claude/settings.json, which also covers git worktrees). Re-running it is safe and upgrades the rules block in place. Other commands never create an empty store silently. The MCP server looks for .brain up the directory tree, so agent worktrees inside the project share the same memory.
Documentation
Architecture: layers, modules, data model, write and read paths, merge rules, search, access control.
Usage: setup, the six MCP tools and
brain_opactions, CLI, HTTP API, the SessionStart hook, the agent workflow.Configuration: environment variables,
settings.json,rules/schemas.json, server flags.Design decisions: why it is built this way, and the known trade-offs.
Performance
uv run python scripts/bench.py 1000 on a laptop (12 threads, SQLite on SSD), 1000 notes of ~1.7 KB:
operation | median | p95 |
write (new version, secret scan, audit) | 6.0 ms | 10.4 ms |
read | 0.2 ms | 0.3 ms |
search (FTS5 + filters + audit) | 170 ms | 189 ms |
On disk: 15.6 MB including indexes and WAL.
Tests
uv run pytest -q # 185 tests, sandbox tests skipped
BRAIN_SANDBOX_TESTS=1 uv run pytest -q # plus sandbox tests (use systemd-run)
uv run pytest -m load # load testsHow it was built
Designed and specified by me; most of the code was written by AI coding agents (opencode and Claude Code) working from the spec in docs/TZ.md, with review and tests before merge. It is used day to day as the memory layer for my own agent-driven projects.
Status
Early (0.2.1), single-tenant, self-hosted. Python 3.12+, stdlib plus minimal dependencies (mcp is optional).
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
A shared team wiki your coding agents read and write — across every repo and every MCP client.
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Shared project context for AI agents and teams: docs, tasks, and messages that stay current.
Hosted markdown project wikis your team's AI assistants read, search, and update over MCP.
Related MCP Servers
- FlicenseAqualityDmaintenanceProvides coding agents with a shared, Markdown-based engineering knowledge base to search, capture, create, and update internal conventions, API details, infrastructure configs, and development setup via lightweight MCP tools.6-
- AlicenseNot gradedqualityCmaintenanceEnables humans and AI coding agents to collaboratively write to a shared knowledge base with conflict-safe claims, code-anchored staleness detection, and synchronized human/agent documentation via MCP and REST.1AGPL 3.0
- FlicenseNot gradedqualityAmaintenanceGives MCP-compatible coding agents a shared, local-first identity and knowledge layer stored as user-owned files, so preferences, quality bars, lessons, decisions, and project context carry across tools and sessions. Writes are AI-proposed but user-reviewable, editable, and overridable, with a read-only preview of exactly what any agent would receive.-
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to read and write team-shared, versioned project memory — atomic claims, numbered ADRs, and long-form docs — over MCP, with a budgeted session-start digest and hybrid search that keep token use low. Agents can also draw on an org-wide shared space written by humans through a web UI.MIT