Mori MCP Server

Shared memory layer for AI coding agents with dream pipeline distillation, session grounding, and multi-instance coherence.

Documentation

Mori — A shared memory layer for AI coding agents

Mori (森) is a shared memory layer for AI coding agents — one that compounds. Sessions feed a dream pipeline that distils activity into durable knowledge, so every instance starts informed rather than cold. One Mori, many agents — every session benefits from what every other session learned.

Works with any OpenAI-compatible provider. No homelab, no Anthropic account, no LLM Gateway required — though those all work too.


Multi-Instance Coherence

One Forest, Many Agents

If you run AI coding agents across multiple machines, profiles, or in a team — one focused on the API layer, another on the frontend, a third on infrastructure — you already know the problem: each instance is brilliant in isolation, but none of them know what the others decided.

Instance B doesn't know that Instance A just changed the auth contract. Instance C doesn't know that Instance B's deployment assumptions shifted. They find out the hard way, mid-task, when something breaks.

Mori solves this. Every coding agent instance sends its session events to the shared Mori server. The dream pipeline distils those events from all instances into a unified memory store. At the start of any session, /brief surfaces what the other instances have been doing. From turn one, each instance knows what the others know.


Quickstart

Runs Anywhere

1. Deploy

See docs/deployment/quickstart.md for all platforms. Docker Compose is the fastest path:

git clone https://github.com/fjwood69/mori.git
cd mori
cp deploy/homelab/.env.example deploy/homelab/.env
# Edit .env with your provider API key
docker compose -f deploy/homelab/docker-compose.yml up -d

2. Verify

curl http://localhost:8968/health
# {"status":"ok","service":"mori-advisor"}

3. Connect your agent

# Claude Code — automated installer:
./scripts/install-mori-claude.sh

# Cursor — automated installer:
./scripts/install-mori-cursor.sh

# Windows:
powershell -File scripts/install-mori-claude.ps1
powershell -File scripts/install-mori-cursor.ps1

Platform guides

PlatformInstallerFull guide
Claude Code./scripts/install-mori-claude.shdocs/getting-started/claude-code.md
Cursor./scripts/install-mori-cursor.shdocs/getting-started/cursor.md
Google Antigravity IDE./scripts/install-mori-antigravity.shdocs/getting-started/antigravity.md
Cline./scripts/install-mori-cline.shdocs/getting-started/cline.md

Capabilities

CapabilityWhat it doesSlash command
Dream pipelineAuto-distils session events into structured memories/dream
Session groundingLoads shared context at session start — not per-query RAG/brief
Universal ingestionFeed PDFs, images, git, transcripts into the memory store/ingest
Strategic reviewLLM guidance with focus areas and auto-injected standards/consult
Requirements trackingLightweight project checklist surfaced via /brief/req
GovernanceVersioning, trusted dreamers, rollback, attribution
NATS messagingReal-time cross-device awareness/nats
Inter-agent messagingSend tasks, questions, and decisions across the device network/msg
Skill deploymentPush slash commands to all devices in one step/update

Full reference: docs/reference/slash-commands.md


How it works

Dream pipeline

Session events are captured via Claude Code lifecycle hooks and distilled into structured memories by a configurable LLM.

Dream Pipeline

Hook fires  →  POST /api/events/raw  →  SQLite events table
                                             ↓
PreCompact  →  POST /api/precompact  →  dream_run() reads since watermark
                                             ↓
                                      LLM distills events → structured memories
                                             ↓
                                      memories written to store (with attribution)
                                             ↓
                                      watermark advanced

The PreCompact hook triggers an immediate synchronous dream before context compression — so nothing is lost at the moment it matters most.

What it captures: PostToolUse, PostToolUseFailure, PreCompact, UserPromptSubmit, Stop — tool calls, prompts, errors, stop reasons, session ID, hostname, working directory, transcript path.

Memory store

The Forest Remembers

Memories live in SQLite (memories.db) with three tiers:

TierScopeLifecycle
EphemeralSession summariesAuto-expire unless explicitly saved
WorkingPatterns, decisions, project contextFlagged after 30 days without retrieval
CanonicalExplicitly promoted by a trusted dreamerIndefinite, freshness-checked via /brief

Versioning, diff, rollback, attribution, and governance built in. See docs/reference/configuration.md.

Universal ingestion

Feed Anything, Remember Everything

New team members start cold. /ingest bootstraps the memory store from existing source material — applying the same distillation pipeline that powers the dream phase.

# Preview (zero cost, no LLM):
/ingest --source ~/my-project --preview

# Dry-run to validate extraction quality:
/ingest --source ~/my-project --dry-run --focus decisions

# Commit:
/ingest --source ~/my-project --focus all --tier working

Supported: PDF, images/whiteboards (Kimi K2.6 vision), CC transcripts (.jsonl), git history (--since 30d), text and code.

Works with remote servers: /ingest reads files on the client device and sends content over the wire — no shared filesystem needed. Works whether mori-advisor is running locally or on GCE.

Cost guard: --max-cost (default $5.00) aborts before spending. Preview is always free. SHA256 dedup prevents re-ingesting the same content.

Strategic consultation (/consult)

Ask hard questions. Get grounded answers.

Ask a question mid-session and get strategic guidance grounded in your actual project context — not generic advice. When a focus area is specified, relevant team standards are automatically pulled from the memory store and injected alongside your question. The advisor checks against your own baseline, not a textbook.

# Architecture review with file context:
/consult "should we move auth to a separate service?" --focus architecture

# Security review against your team's own baseline:
/consult "review this handler" --focus security --file src/auth.py

# Chain tool output directly into the advisor:
/consult "review this" --focus security --file src/auth.py --file snyk-report.json

Focus areas: general, architecture, security, performance, style

Depth levels: quick (fast scan), balanced (default), deep (thorough)

Standards-aware: set MORI_STANDARDS_DIR to a directory of .md files and Mori imports them as protected memories. /consult --focus security automatically injects your security baseline — your agents check against your rules, not generic ones.

Inter-agent messaging (/msg)

The forest whispers

Delegate tasks, ask questions, and share decisions across your Claude Code instances — without a shared session. Messages are typed, reply-threaded, and picked up at the next /brief. The mori-msg daemon receives messages server-side: decision messages are written directly to the memory store without any human session on the receiving end.

# From UX3405, delegate a task to the NUC:
/msg send nuc15pro task "Refactor auth middleware — extract rate limiting into its own module"

# NUC picks it up at next /brief and acks:
/msg ack a3f9c2b1 "on it"

# Back on UX3405, check the reply:
/msg inbox

# NUC marks it done when finished:
/msg done a3f9c2b1

Message types: task, decision, question, reply, ack, done, broadcast

Requires the mori-msg daemon running alongside mori-advisor (included in the default pod stack). See docs/reference/msg.md for full reference.

Architecture

Mori Architecture


Configuration

Configuration referencedocs/reference/configuration.md Recommended modelsdocs/reference/models.md For teamsdocs/for-teams.md Team configuration referencedocs/reference/team-configuration.md

Key environment variables:

VariableDefaultDescription
MORI_PROVIDER_MODEbifrostdirect or bifrost
MORI_API_KEYProvider key (required in direct mode)
MORI_BASE_URLOpenAI-compatible base URL
MORI_MODELmoonshotai/kimi-k2.6Advisor + consult model
MORI_DREAM_MODELfalls back to MORI_MODELDream + ingest distillation model
MORI_FAST_MODELdeepseek/deepseek-v4-flashContradiction scan + freshness checks
MORI_API_KEYSNamed client API keys: name:secret,name:secret,... — see Authentication
MORI_TRUSTED_DREAMERSComma-separated trusted hostnames
MORI_DREAM_INTERVAL60Dream cron interval (minutes)
MORI_STANDARDS_DIRPath to team standards .md files
MORI_MSG_HEADLESS_ENABLEDfalseSpawn headless Claude for incoming tasks
MORI_MSG_HEADLESS_TRUSTEDComma-separated hostnames allowed to trigger headless CC

Authentication: Set MORI_API_KEYS to give each client a named key. Without it the server starts in open mode (fine for private Tailscale networks; always set keys for shared or internet-accessible deployments). Generate secrets with python3 -c "import secrets; print(secrets.token_hex(32))". Full details: docs/reference/configuration.md → Authentication.


Building

git clone https://github.com/fjwood69/mori.git
cd mori
podman build -t localhost/mori-advisor:latest .
# Or: docker build -t mori-advisor:latest .

License

License: AGPL v3

AGPL-3.0 — see LICENSE. Commercial licences available — see COMMERCIAL.md.


Support me on Ko-fi