Neverinfamous Memory Journal MCP README

The full upstream README, mirrored for reference. Install config, tool schemas, adoption signals and our own overview live on the Neverinfamous Memory Journal MCP listing page.

Memory Journal MCP Server

GitHub npm Docker Pulls License: MIT Status MCP Registry Security GitHub Stars TypeScript Coverage E2E Tests Benchmarks CI

πŸ“š Full Documentation (Wiki) β€’ Changelog β€’ Security β€’ Release Article

[!TIP] Your own private, encrypted SQLite project memory β€” portable across every AI client. Switch seamlessly between Claude, Cursor, Copilot, Antigravity, and any MCP-compatible agent without vendor lock-in or rebuilding history by hand. Recall past decisions, load adaptive session briefings, and hand work off through GitHub.

πŸš€ Quick Deploy:

  • npm Package - npm install -g memory-journal-mcp (or pnpm add -g memory-journal-mcp)
  • Docker Hub - Alpine-based with full semantic search

🧠 Eliminate AI Amnesia

Large projects face a critical challenge. You lose context between sessions.

  • Stop Thread Amnesia - AI conversations start fresh. They ignore previous work.
  • Retain Deep Context - Decisions and code scatter across threads; Memory Journal preserves them automatically.
  • End Repeated Work - AI repeats failed solutions; persistent history tracks every prior attempt.
  • Prevent Context Overload - Manual history copying wastes tokens; dynamic briefings deliver targeted context automatically.

Memory Journal builds your project's long-term memory. It acts as a Project Context Graph for AI-assisted engineering. It bridges human workflows (Issues, PRs, Kanban, Milestones) with agent execution (Git, tests, decisions).


Experience true context-aware development:

  • "Why did we choose SQLite over Postgres for this service last month?" (Semantic search)
  • "Run the /issue-commander (triage workflow) on the top priority ticket in the Kanban board." (GitHub operations)
  • "Who has been touching the auth module recently, and what's our team collaboration density?" (Team analytics)
  • "Commit the changes and record a structured journal entry with the commit prompt or create_entry." (Automated lifecycles)
  • "Draw a visual graph showing how my last 10 architectural decisions relate to each other." (Knowledge graph)

Comprehensive access to internal state via resources (memory://briefing, memory://repo-map, memory://workflows, memory://rules, memory://skills, memory://health, memory://help, memory://staleness, memory://graph, GitHub status/milestones, team stats, and metrics/latency). Dynamic repo variants also support cross-repo targeting (like memory://briefing/{+repo}, memory://repo-map/{+repo}, memory://agent-context/{+repo}, memory://graph/{+repo}, or memory://kanban/{+repo}/{project_number}). Resources documentation β†’


🎯 What Sets Us Apart

MCP Tools Β· Workflow Prompts Β· Resources Β· Tool Groups Β· Code Mode Β· Cognitive Automations (CMS) Β· GitHub Commander (Issue Triage, PR Review, Milestone Sprints, Security/Quality/Perf Audits) Β· GitHub Integration (Issues, PRs, Actions, Kanban, Milestones, Insights) Β· Team Collaboration (Shared DB, Vector Search, Cross-Project Insights)

FeatureDescription
Session IntelligenceAuto-query project history, create checkpoints, and hand off context between sessions automatically.
Cognitive AutomationsConsolidate episodic notes nightly (CMS-02), audit soft-deletions, and self-heal recurring tool friction (CMS-04).
GitHub IntegrationManage Issues, PRs, Actions, Kanban boards, and milestones. Access Copilot reviews and repository insights.
Dynamic Project RoutingSwitch contexts seamlessly and access CI/Issue tracking across multiple repositories from a single server instance.
Knowledge GraphsLink specifications, implementations, tests, and PRs visually using Mermaid diagrams.
Hybrid SearchFind entries instantly using a blend of keyword, semantic, and date-range searches.
Code ModeExecute multi-step operations efficiently in a sandboxed environment to reduce token usage.
Adaptive Session BriefingDeliver zero-waste workspace context dynamically: live CI health, ahead/behind & dirty-file decision overlap, live memory://repo-map/{+repo} & code-map.md pointers, actionable config alerts, conditional blockers/stale anchors, and History-Impact commit velocity.
Live Repo MapsServe read-only, token-budgeted file trees (memory://repo-map/{+repo} & CLI admin repo-map) with live file counts, cached single-pass git recency, SQLite entry_anchors, automatic header/label extraction, and code-map.md section discovery for any repository with zero external scripts.
Reports & AnalyticsGenerate standups, retrospectives, PR summaries, digests, and period analyses.
Heuristic ScoringOptimize context delivery by scoring entries based on veracity and impact.
Team CollaborationShare databases across teams with cross-project insights, author attribution, and role-based access control.
Data InteroperabilityExport schemas safely, sync Markdown directories, and maintain a unified IO namespace.
Backup & RestoreSecure data with CLI/CMS maintenance automation, retention policies, and one-command restores.
Auto-PruningSoft-delete low-value entries automatically to maintain search relevance over long-running projects.
Security & TransportEnsure secure connections with OAuth 2.1, Streamable HTTP, rate limiting, and SQL injection prevention.
Structured Error HandlingProvide agents with classification, remediation hints, and recoverability signals on every tool call.
Agent CollaborationShare context between IDE agents and Copilot. Search review findings and let agents suggest reusable rules.
Native Agent SkillsEstablish permanent AI behavior and architecture rules using bundled foundational coding paradigms.
GitHub CommanderAudit code, triage issues, review PRs, and run sprint milestones via automated pipeline skills.

Isolate Environments with Multi-Tenancy

Memory Journal supports multi-tenancy out of the box via the workspace_id construct, acting as a strict isolation barrier for multiple journals sharing the same SQLite database file.

  • Auto-Resolution: When workspace_id is omitted, the server automatically resolves the target workspace. It matches project_number against PROJECT_REGISTRY or inspects process.cwd() before falling back to DEFAULT_WORKSPACE_ID (default: default).
  • Data Partitioning & Cross-Workspace Queries: Core CRUD, Soft-Delete/Restore, FTS5 Search, Vector Semantic Search (semantic_search), and Analytics tools enforce workspace_id isolation end-to-end. Read and search tools accept workspace_id: "*" to query across all workspaces. create_entry rejects workspace_id: "*" with VALIDATION_ERROR. update_entry with workspace_id: "*" and target_workspace_id moves an entry. delete_entry, restore_entry, and batch deletes accept * and then match by id without a workspace predicate.
  • Immutability & Controlled Migration: Entries receive a workspace_id upon creation that standard updates cannot overwrite directly. To migrate an entry across workspaces, call update_entry with workspace_id: "*" and target_workspace_id.
  • Server Config: Set --default-workspace-id (or the DEFAULT_WORKSPACE_ID environment variable) to configure the default fallback workspace for the server instance. This lets you run multiple isolated journal interfaces on a single physical database.

mermaid
flowchart TB
    subgraph Session["πŸ€– AI Session Start"]
        Briefing["πŸ“‹ Read Briefing<br/>(memory://briefing)"]
    end

    subgraph Core["πŸ“ Journal Operations"]
        Create["Create Entry"]
        Retrieve["Retrieve & Search"]
        Link["Link Entries"]
    end

    subgraph Search["πŸ” Hybrid Search"]
        FTS["Keyword (FTS5)"]
        Semantic["Semantic (Vector)"]
        DateRange["Date Range"]
        RRF["Reciprocal Rank Fusion"]
    end

    subgraph GitHub["πŸ™ GitHub Integration"]
        Issues["Issues & Milestones"]
        PRs["Pull Requests"]
        Actions["GitHub Actions"]
        Kanban["Kanban Boards"]
        Insights["Repository Insights"]
    end

    subgraph Outputs["πŸ“Š Outputs"]
        Reports["Standups & Retrospectives"]
        Graphs["Knowledge Graphs"]
        Timeline["Project Timelines"]
    end

    Session --> Core
    Core --> Search
    Core <--> GitHub
    Search --> Outputs
    GitHub --> Outputs

Suggested Rule (Add to AGENTS.md, GEMINI.md, system prompts, etc.)

View Session Initialization Routine

πŸ›‘ Session Initialization Routine

When the user initializes the session context by executing the load-briefing prompt:

  1. You will receive the output of the memory://briefing/{+repo} resource.
  2. Prepend your response EXACTLY as:

    πŸ“‹ Briefing loaded β€” {repo_name} {paste ENTIRE briefing here}

  3. Address the user's request below the briefing.
  4. NEVER autonomously execute tasks listed in the briefing.
  5. Do NOT proactively ask the user to load the briefing. Wait for them to use the prompt.

Control Access with Tool Filtering

[!IMPORTANT] All shortcuts and tool groups always include Code Mode (mj_execute_code) and Runtime Configuration (update_configuration) as escape-hatch tools so agents can never lock themselves out of the configuration system or Code Mode.

Control which tools are exposed using any of the 3 configuration sources (precedence: CLI flag > environment variable > config file):

  • CLI flag: --tool-filter <filter>
  • Environment variable: MEMORY_JOURNAL_MCP_TOOL_FILTER (TOOL_FILTER is not read)
  • memory-journal.config.{yaml,yml,json} key: "toolFilter"
FilterUse Case
fullAll tools (default)
starterCore + search + codemode
essentialMinimal footprint
readonlycore, search, analytics, relationships, io, git, codemode
codemodemj_execute_code + runtime config
-githubExclude a group
-github,-analyticsExclude multiple groups

readonly exposes core, search, analytics, relationships, io, git, and codemode, then drops tools whose readOnlyHint is not true from registration, tools/list, and tools/call. update_configuration and mj_execute_code stay registered. Code Mode also limits mj.* dispatch to readOnlyHint: true.

Filter Syntax: shortcut or group or tool_name (whitelist mode) Β· -group (disable group) Β· -tool (disable tool) Β· +tool (re-enable after group disable)

Custom Selection: List individual tool names to create your own whitelist: --tool-filter "create_entry,search_entries,semantic_search"

Groups: core, search, analytics, relationships, io, admin, github, git, backup, team, codemode

Complete tool filtering guide β†’


πŸ“‹ Unlock Core Capabilities

πŸ› οΈ MCP Tools

GroupDescription
codemodeCode Mode (sandboxed code execution) 🌟 Recommended
coreEntry creation/read/history, tags, resource & briefing helpers, anchor staleness, test
searchText search, date range, semantic, vector stats, deleted entries, cross-team
analyticsStatistics, cross-project insights
relationshipsLink entries, visualize graphs
ioJSON/Markdown export, Markdown directory import/export, and external knowledge base import (Notion, Obsidian, Logseq)
adminUpdate configuration, project registry management, entry update/delete/restore, rebuild/add to vector index, merge tags, search audit log, auto-prune, database optimization (optimize_database), bulk operations (batch create/update/delete)
githubIssues, PRs, context, Kanban, Milestones, Insights, issue lifecycle, Copilot Reviews
gitCommit history, search, release info, patterns, staleness checks
backupBackup, list, restore, cleanup
teamCRUD, search, stats, relationships, IO (Markdown & external import/export), backup, vector search, cross-project insights, matrix, RBAC member management, author aliases (requires TEAM_DB_PATH)

Complete tools reference β†’

🎯 Workflow Prompts

Specialized workflow prompts cover session briefing, standup & retro prep, goal tracking, PR & issue command, session summaries, and journal optimization. Additional prompts support CMS REM supervision, adversarial plan reviews, code & security audits, secure commit workflows, and anti-hallucination healing. Complete prompts guide β†’ β€’ Automations guide β†’

πŸ“‘ Resources

See the Complete resources guide β†’ for the full list of dynamic context resources, including memory://briefing, memory://instructions, GitHub integration endpoints, telemetry metrics, and templated views.

  • Dynamic Resource Templates: Resources memory://briefing/{+repo}, memory://agent-context/{+repo}, memory://agent-id/{+repo}, memory://graph/{+repo}, memory://repo-map/{+repo}, memory://actions/recent/{+repo}, memory://github/status/{+repo}, memory://github/milestones/{+repo}, memory://milestones/{+repo}/{number}, and memory://kanban/{+repo}/{project_number} accept an RFC 6570 {+repo} path parameter for targeted project context.

⚑ Code Mode

Code Mode (mj_execute_code) runs many journal operations in one sandboxed call, so the client does not resend every tool schema. Instead of spending thousands of tokens on sequential tool calls, AI agents use a single sandboxed execution to reason faster.

Code executes in a pre-warmed worker_threads V8 isolate pool + secondary vm.createContext boundary designed as a secure multi-tenant process isolation environment. All mj.* API calls execute against the journal within the sandbox, providing:

  • V8 code generation restrictions β€” eval() and Function() construction from strings disabled at the V8 engine level via codeGeneration: { strings: false, wasm: false }
  • Frozen prototypes & cross-realm constructor lockdown β€” all built-in prototypes (Object, Function, Array, Error, etc.) and mj.* API bindings are frozen, .constructor is neutered on Function, AsyncFunction, GeneratorFunction, AsyncGeneratorFunction, Generator, and AsyncGenerator prototypes in both the inner vm realm and outer worker realm (and on Object.prototype in the outer worker realm, while the inner vm realm deletes Object.prototype.__proto__ and freezes Object and Object.prototype) to prevent dynamic constructor chain escapes
  • Single-pass lexical validation β€” pre-validation rate-limiting and 50KB byte caps run before any code normalization, followed by a single-pass lexical comment/string scanner (preserving ${...} template expressions) and static rules blocking require(), import(), process, eval(), Reflect.*, Symbol.*, Object.getPrototypeOf/setPrototypeOf/defineProperty, new Proxy(), and filesystem/network access
  • Proxy constructor nullified β€” Proxy: undefined in the sandbox prevents meta-object protocol abuse
  • Prototype-safe RPC allowlist β€” host-side Object.hasOwn() validation, recursion-bounded argument normalization, and --tool-filter enforcement prevent workers from invoking unauthorized or filtered API methods
  • Rate limiting β€” 60 executions per minute per client
  • Hard timeouts β€” configurable execution limit (default 30s) with bounded async timer tracking (setTimeout/sleep capped and cleared on completion)
  • Egress boundary enforcement β€” result serialization capped (default 100KB via CODE_MODE_MAX_RESULT_SIZE) with automatic payload compaction to prevent OOM via oversized payloads
  • Full API access β€” all tool groups are available via mj.* (e.g., mj.core.createEntry(), mj.search.searchEntries(), mj.github.getGithubIssues())
  • Readonly filter β€” A filter containing readonly (and not -readonly) drops tools whose readOnlyHint is not true from registration, tools/list, and tools/call. update_configuration and mj_execute_code stay registered. Code Mode also limits mj.* dispatch to readOnlyHint: true.

⚑ Code Mode Minimal Surface (Maximum Token Savings)

Run with the codemode filter and --codemode-internal-full-access to expose only the escape-hatch tools (mj_execute_code and update_configuration) on the MCP tool list while retaining full internal access to the mj.* API inside the sandbox:

config.json
{
  "mcpServers": {
    "memory-journal-mcp": {
      "command": "memory-journal-mcp",
      "args": ["--tool-filter", "codemode", "--codemode-internal-full-access"]
    }
  }
}

This exposes only mj_execute_code and update_configuration to the client's tools/list, reducing tool schema overhead to the minimum while preserving full programmatic capability via mj.*. The agent writes JavaScript against the typed mj.* SDK β€” composing operations across all tool groups and returning exactly the data it needs β€” in one execution. This mirrors the Code Mode pattern pioneered by Cloudflare for their entire API: fixed token cost regardless of how many capabilities exist. Without --codemode-internal-full-access (or CODEMODE_INTERNAL_FULL_ACCESS=true), internal mj.* methods are scoped to the active --tool-filter.


πŸš€ Quick Start & Deployment

Note: Configuration is resolved using strict precedence: CLI flags > Environment Variables > Config File > Defaults (see memory-journal-config-example.json, examples/configs/memory-journal.config.yaml, mcp-config-example.json, and examples/).

[!NOTE] Debugging configuration: Run memory-journal-mcp --dump-config (or pass --dump-config as an arg) to print the fully resolved configuration payload with automatically redacted secrets. This is the primary method for diagnosing overriding issues.

Configure Basics Quickly

[!TIP] npx memory-journal-mcp project create <name> --path <repo-path> [--number <project-number>] writes projectRegistry to memory-journal.config.json (default ~/.gemini/config/memory-journal.config.json, or MEMORY_JOURNAL_CONFIG). It does not edit the PROJECT_REGISTRY environment variable. A PROJECT_REGISTRY value in the MCP client overrides the file. Leave PROJECT_REGISTRY unset so the server loads that file.

config.json
{
  "mcpServers": {
    "memory-journal-mcp": {
      "command": "memory-journal-mcp",
      "env": {
        "GITHUB_TOKEN": "ghp_your_token_here",
        "PROJECT_REGISTRY": "{\"my-repo\":{\"path\":\"/path/to/your/git/repo\",\"project_number\":1}}",
        "ALLOWED_IO_ROOTS": "/path/to/your/git/repo"
      }
    }
  }
}

Power Up with Advanced Configuration

Showcasing the full power of the server, including Multi-Project Routing, Team Collaboration, Copilot awareness, and Context Injections.

config.json
{
  "mcpServers": {
    "memory-journal-mcp": {
      "command": "memory-journal-mcp",
      "args": ["--tool-filter", "codemode"],
      "env": {
        "DB_PATH": "/path/to/your/memory_journal.db",
        "TEAM_DB_PATH": "/path/to/shared/team.db",
        "GITHUB_TOKEN": "ghp_your_token_here",
        "PROJECT_REGISTRY": "{\"my-repo\":{\"path\":\"/path/to/repo\",\"project_number\":1},\"other-repo\":{\"path\":\"/path/to/other\",\"project_number\":5}}",
        "ALLOWED_IO_ROOTS": "/path/to/repo,/path/to/other,/path/to/your/skills",
        "AUTO_REBUILD_INDEX": "true",
        "CODEMODE_INTERNAL_FULL_ACCESS": "true",
        "BRIEFING_ENTRY_COUNT": "3",
        "BRIEFING_SUMMARY_COUNT": "1",
        "BRIEFING_INCLUDE_TEAM": "true",
        "BRIEFING_ISSUE_COUNT": "3",
        "BRIEFING_PR_COUNT": "3",
        "BRIEFING_PR_STATUS": "true",
        "BRIEFING_WORKFLOW_COUNT": "3",
        "BRIEFING_WORKFLOW_STATUS": "true",
        "BRIEFING_COPILOT_REVIEWS": "true",
        "RULES_FILE_PATH": "/path/to/your/RULES.md",
        "SKILLS_DIR_PATH": "/path/to/your/skills",
        "MEMORY_JOURNAL_WORKFLOW_SUMMARY": "/deploy: prod deployment | /audit: security scan",
        "AUDIT_LOG_PATH": "/path/to/your/mcp-audit.jsonl",
        "TEAM_AUTHOR": "your_username"
      }
    }
  }
}

[!TIP] Optimize your context window! Journal entries (BRIEFING_ENTRY_COUNT) should complement Git commits β€” capture the why, rejected alternatives, invariants, and open risks rather than restating commit diffs. Session summaries (BRIEFING_SUMMARY_COUNT) surface high-level retrospectives across AI sessions.

πŸ“‹ Customizing the Session Briefing

The memory://briefing resource is dynamically assembled at each session start with zero-waste suppression (any setting set to 0 or false skips both its rendered output and its underlying GitHub API, SQLite, or git work). By default, it automatically surfaces:

  • Repository & Tracking: Active branch (with ahead/behind sync indicators when non-zero), CI workflow status, local dirty tree status with anchored-decision overlap (Dirty (XM, YU) Β· touches #id, 0 queries on clean trees), open issues/PRs, active branch PR, Copilot reviews, and milestones.
  • Journal & Graph: Recent personal entries (prioritizing non-commit-narrative entries when Git History is enabled), optional team entries, session summaries, 14-day knowledge graph pivots (node degrees, active threads, unresolved Blocked: edges, persisted Stale anchors:, commitβ†’entry links, linkage rate), and recent git commits with History-Impact trailer velocity.
  • Config & Insights: Actionable config alerts only (read-only mode, missing team/GitHub config when enabled, I/O roots β€” omitted completely when empty), repo stats/traffic, analytics digest, and optional health/deprecation alerts.

You control exactly what additional content your agent sees across three dimensions:

DimensionVariablesWhat It Controls
FocusMEMORY_JOURNAL_MCP_TOOL_FILTER (CLI: --tool-filter, config: "toolFilter")Control tool exposure: full (default), starter, essential, readonly, codemode
Journal ContentBRIEFING_ENTRY_COUNT, BRIEFING_SUMMARY_COUNT, BRIEFING_COMMIT_COUNT, BRIEFING_IMPORTANCE_THRESHOLD, BRIEFING_INCLUDE_TEAM, BRIEFING_GRAPH, BRIEFING_INSIGHTSHow many recent entries, session summaries, commits, whether team entries, graph pivots, and the Insights row appear
GitHub EnrichmentBRIEFING_ISSUE_COUNT, BRIEFING_PR_COUNT, BRIEFING_PR_STATUS, BRIEFING_MILESTONE_COUNT, BRIEFING_WORKFLOW_COUNT, BRIEFING_WORKFLOW_STATUS, BRIEFING_COPILOT_REVIEWSIssues, PRs, milestones, CI runs, and Copilot review state surfaced in the briefing

Context Injections: Set RULES_FILE_PATH and SKILLS_DIR_PATH to surface user rules and agent skills as companion resources (memory://rules, memory://skills) alongside the briefing.

Repo Targeting: In multi-repo setups, agents read memory://briefing/{+repo} to get a briefing scoped to a specific repository registered in PROJECT_REGISTRY.

Briefing Presets (click to expand)

Minimal (fast sessions) β€” Reduce briefing to bare essentials for quick interactions:

config.json
{
  "BRIEFING_ENTRY_COUNT": "1",
  "BRIEFING_SUMMARY_COUNT": "0",
  "MEMORY_JOURNAL_MCP_TOOL_FILTER": "essential"
}

Full Context (onboarding agents) β€” Maximize context for agents unfamiliar with the project:

config.json
{
  "BRIEFING_ENTRY_COUNT": "5",
  "BRIEFING_SUMMARY_COUNT": "3",
  "BRIEFING_INCLUDE_TEAM": "true",
  "BRIEFING_ISSUE_COUNT": "5",
  "BRIEFING_PR_COUNT": "3",
  "BRIEFING_PR_STATUS": "true",
  "BRIEFING_COPILOT_REVIEWS": "true",
  "MEMORY_JOURNAL_MCP_TOOL_FILTER": "full"
}

DevOps-Heavy β€” Emphasize CI/CD and GitHub state for infrastructure workflows:

config.json
{
  "BRIEFING_WORKFLOW_COUNT": "5",
  "BRIEFING_WORKFLOW_STATUS": "true",
  "BRIEFING_ISSUE_COUNT": "3",
  "BRIEFING_PR_COUNT": "3",
  "BRIEFING_PR_STATUS": "true",
  "BRIEFING_COPILOT_REVIEWS": "true"
}

Full briefing customization guide β†’

Variants (modify the config above):

VariantChange
Minimal (no GitHub)Remove the env block entirely
npx (no install)Replace "command" with "npx" and add "args": ["-y", "memory-journal-mcp"]
From sourceReplace "command" with "node" and add "args": ["dist/cli.js"]
Code Mode minimalAdd "args": ["--tool-filter", "codemode", "--codemode-internal-full-access"] (mj_execute_code + update_configuration, all mj.* capabilities)
DockerReplace "command" with "docker" and add "args": ["run", "-i", "--rm", "-v", "./data:/app/data", "-e", "GITHUB_TOKEN", "-e", "PROJECT_REGISTRY", "-e", "ALLOWED_IO_ROOTS", "writenotenow/memory-journal-mcp:latest"] (forward any "env" keys via -e <VAR>)
Team collaborationAdd "TEAM_DB_PATH": "./team.db" to env

Restart your MCP client and start journaling!

Connect Remotely with HTTP/SSE Transport

[!IMPORTANT] Stdio and HTTP/SSE transports follow distinct security postures (HTTP enforces three fail-closed startup guards):

  • Stdio (Default): Runs implicitly within the secure boundaries of your local IDE or command-line environment. No explicit authentication is required because the execution context is already trusted (ALLOWED_IO_ROOTS defaults to fail-closed [] unless configured).
  • HTTP/SSE (--transport http): Exposes the server over a network socket and enforces three fail-closed startup guards:
    1. Mandatory Filesystem Boundary (ALLOWED_IO_ROOTS / --allowed-io-roots): Always required in HTTP mode so filesystem boundaries are explicitly declared.
    2. Mandatory Public Authentication: By default, HTTP binds ONLY to localhost and blocks wildcard CORS to prevent unauthorized access and CSRF attacks. Binding to a non-loopback address (--server-host 0.0.0.0) requires explicit authentication (MCP_AUTH_TOKEN / --auth-token or --oauth-enabled).
    3. Mandatory Public Origin for Non-Loopback OAuth (PUBLIC_ORIGIN / --public-origin): When --oauth-enabled is bound to a non-loopback address, --public-origin (PUBLIC_ORIGIN) is strictly required so RFC 9728 Protected Resource Metadata cannot be spoofed via Host headers.

For remote access or web-based clients, run the server in HTTP mode:

bash
memory-journal-mcp --transport http --port 3000 --allowed-io-roots /path/to/allowed/dir

To bind to all interfaces (required for containers), you MUST provide both ALLOWED_IO_ROOTS and an authentication token:

server.ts
export MCP_AUTH_TOKEN="your_secure_random_token"
export MCP_AUTH_SCOPES="full" # Defaults to "read" if omitted
export ALLOWED_IO_ROOTS="/path/to/allowed/dir"
memory-journal-mcp --transport http --port 3000 --server-host 0.0.0.0

Endpoints:

EndpointDescriptionMode
GET /Server info and available endpointsBoth
POST /mcpJSON-RPC requests (initialize, tools/call, etc.)Both
GET /mcpSSE stream for server-to-client notificationsStateful
DELETE /mcpSession termination (204 No Content)Both
GET / POST /sseLegacy SSE connection & stateless/stateful POST (MCP 2024-11-05)GET: Stateful / POST: Both
POST /messagesLegacy SSE message endpointStateful
GET /healthHealth check ({ status, timestamp })Both
GET /metricsPrometheus metrics export (requires flag; Bearer token or OAuth audit scope when auth enabled)Both
GET /.well-known/oauth-protected-resourceRFC 9728 Protected Resource Metadata (requires --oauth-enabled)Both

Session Management: The server uses stateful sessions by default. Include the mcp-session-id header (returned from initialization) in subsequent requests.

  • OAuth 2.1 β€” RFC 9728/8414, JWT/JWKS, granular scopes (opt-in via --oauth-enabled)
  • Comprehensive Security Headers β€” CSP, HSTS (opt-in), X-Frame-Options, and more
  • Rate Limiting β€” 100 req/min per client IP (SHA-256 of client IP) Β· CORS β€” configurable multi-origin (exact-match) Β· 1MB body limit
  • Server Timeouts β€” Request (120s), keep-alive (65s), headers (66s) Β· 404 handler Β· Cross-protocol guard
  • Build Provenance Β· SBOM Β· Supply Chain Attestations Β· Non-root execution

Example with curl:

Initialize session (returns mcp-session-id header):

Terminal
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'

List tools (with session):

Terminal
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "mcp-session-id: YOUR_SESSION_ID" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'

Stateless Mode (No-Session HTTP)

For container or load-balanced Node deployments without sticky sessions (requires a Node process with a local SQLite file; edge/serverless runtimes are not supported), use stateless mode:

bash
memory-journal-mcp --transport http --port 3000 --stateless --allowed-io-roots /path/to/projects
ModeProgress NotificationsLegacy SSEHorizontal Scaling
Stateful (default)βœ… Yesβœ… Yes⚠️ Sticky sessions
Stateless (--stateless)❌ No❌ Noβœ… Any instance

Maintenance, Auto-Prune & Scheduled Jobs

Startup auto-prune enforces two-stage data lifecycle hygiene automatically on boot (0 = disabled), and one-shot admin CLI subcommands handle database maintenance (backup, restore, vacuum, prune, rebuild-index) without running a background scheduler inside the MCP server.

[!NOTE] For recurring automation across IDE sessions, use client-driven Nightly CMS Automations β†’ (CMS-02 / CMS-04) or OS-level scheduling (cron, Windows Task Scheduler) invoking memory-journal-mcp admin <command> or mj_execute_code tools directly.

bash
memory-journal-mcp --archive-older-than-days 90 \
  --prune-older-than-days 5 --hard-delete-older-than-days 5 \
  --prune-importance-threshold 0.15

# One-shot maintenance commands (stdio or headless hosts)
memory-journal-mcp admin backup
memory-journal-mcp admin vacuum
memory-journal-mcp admin prune
memory-journal-mcp admin rebuild-index
FlagDefaultDescription
--archive-older-than-days <days>0 (off)Auto-archive low-importance entries older than N days on startup / prune
--prune-older-than-days <days>0 (off)Auto soft-delete entries older than N days on startup / prune
--hard-delete-older-than-days <days>0 (off)Permanently purge soft-deleted entries older than N days on startup / prune
--prune-importance-threshold <score>0.15Max importance score (0.0–1.0) eligible for archiving/pruning
--prune-dry-runfalseLog auto-prune candidates without mutating entries
--prune-exclude-tags <tags>β€”Comma-separated tags exempt from auto-prune (default: [] β€” only tags passed here are exempt; is_archived = 1 skips re-archiving while soft-delete selects by age and importance)

Integrate Seamlessly with GitHub

The GitHub tools (get_github_issues, get_github_prs, etc.) auto-detect the repository from your git context when PROJECT_REGISTRY is configured or the MCP server is run inside a git repository.

Multi-Project Workflows: npx memory-journal-mcp project create <name> --path <repo-path> [--number <project-number>] writes projectRegistry to memory-journal.config.json (default ~/.gemini/config/memory-journal.config.json, or MEMORY_JOURNAL_CONFIG). It does not edit the PROJECT_REGISTRY environment variable. A PROJECT_REGISTRY value in the MCP client overrides the file. Leave PROJECT_REGISTRY unset so the server loads that file.

Dynamic Context Resolution & Auto-Detection

When executing GitHub tools (issues, PRs, context, etc.), the server resolves repository context in this order:

  1. Dynamic Project Routing: If the agent passes a repo string that matches a key in your PROJECT_REGISTRY, the server dynamically mounts the physical directory mapped to that project. It executes git commands locally and automatically infers the owner.
  2. Explicit Override: If the agent provides both owner and repo explicitly, those values override auto-detection for API calls.
  3. Missing Context: Without PROJECT_REGISTRY or explicit parameters, the server blocks execution and returns {requiresUserInput: true} to prompt the agent. If an agent encounters this blocked state, it can seamlessly recover by invoking the mj.admin.registerProject() method via Code Mode to auto-configure the project registry on the fly.

Automatic Project Routing (Kanban / Issues)

When opening an issue or viewing/moving a Kanban card, the server needs a GitHub Project number. It determines this via:

  1. Exploring the raw project_number argument passed by the agent.
  2. Checking if the repo string precisely matches an entry in your PROJECT_REGISTRY, seamlessly mapping it to its pre-configured project_number.
  3. Falling back to the globally defined DEFAULT_PROJECT_NUMBER if set.

πŸ” OAuth 2.1 Authentication

For production deployments, enable OAuth 2.1 authentication on the HTTP transport:

ComponentStatusDescription
Protected Resource Metadataβœ…RFC 9728 /.well-known/oauth-protected-resource
Auth Server Discoveryβœ…RFC 8414 metadata discovery with caching
Token Validationβœ…JWT validation with JWKS support
Scope Enforcementβœ…Granular read, write, team, audit, admin, full scopes
HTTP Transportβœ…Streamable HTTP with OAuth middleware

Supported Scopes:

ScopeTool Groups
readcore (read-only), search (except cross_team_search), analytics, relationships (visualize_relationships), io (export_entries), git (except check_entry_staleness), admin (get_project, list_projects)
writegithub (+ all read groups and create_entry / link_entries / mark_anchors_stale / check_entry_staleness / import_external / import_markdown / export_markdown)
teamteam (non-admin), cross_team_search (dedicated team collaboration scope; combine with read/write for personal journal access)
auditmemory://audit, search_audit_log, memory://metrics/users, OAuth GET /metrics, and Prometheus per-user metrics (included in admin/full)
adminadmin (except get_project / list_projects / search_audit_log), backup, codemode, team admin tools (+ all read/write/team/audit groups)
fullUnrestricted access to all operations

Quick Start:

bash
memory-journal-mcp --transport http --port 3000 \
  --allowed-io-roots /path/to/projects \
  --oauth-enabled \
  --oauth-issuer https://auth.example.com/realms/mcp \
  --oauth-audience memory-journal-mcp \
  --oauth-jwks-uri https://auth.example.com/realms/mcp/protocol/openid-connect/certs

Or via environment variables:

server.ts
export ALLOWED_IO_ROOTS="/path/to/projects"
export OAUTH_ENABLED=true
export OAUTH_ISSUER=https://auth.example.com/realms/mcp
export OAUTH_AUDIENCE=memory-journal-mcp
export OAUTH_JWKS_URI=https://auth.example.com/realms/mcp/protocol/openid-connect/certs
export OAUTH_CLOCK_TOLERANCE=60
memory-journal-mcp --transport http --port 3000

[!NOTE] OAuth is opt-in. When not enabled, the server falls back to simple token authentication via MCP_AUTH_TOKEN environment variable, or runs without authentication. For a turnkey local Keycloak 26.8.2 OAuth 2.1 Compose setup, see examples/oauth-keycloak/.

πŸ”„ Session Management

  1. Session start β†’ agent reads memory://briefing (or memory://briefing/{+repo}) and shows project context
  2. Session summary β†’ use /session-summary to capture progress and next-session context
  3. Next session's briefing includes the previous summary β€” context flows seamlessly

πŸŒ™ Automate Nightly Cognitive Maintenance (CMS)

Keep project memory self-cleaning, drift-free, and self-healing across stdio and HTTP setups using the Cognitive Management System (CMS):

  • Session Hooks & Issue Telemetry β€” Pair client SessionStart / PostToolUse hooks (Google Antigravity hooks.json, Cursor .cursor/hooks.json) with built-in server error telemetry (logs/agent-issues.jsonl) to inject workspace_id + project_number context at startup and capture validation friction automatically.
  • CMS-02: NREM Memory Consolidation (optimize-journal) β€” Unattended closed-loop, self-improving NREM curation: timestamped backups, unassigned entry migration, Git/GitHub ground-truth & anchor staleness checks, episodic-to-semantic compaction, tag/graph defrag, auto-pruning, vector index parity, physical SQLite optimization (optimize_database), and proactive prompt/code/doc fixes behind a conditional targeted gate.
  • CMS-04: REM Meta-Cognitive Supervisor (cms-rem-supervisor) β€” Meta-Plane closed-loop supervisor: automatic restoration of erroneously soft-deleted high-value entries, logs/agent-issues.jsonl telemetry mining, and proactive code/schema/prompt/doc healing behind a Targeted Code-vs-Docs Single-Pass Validation Gate.

Trigger either workflow on demand or via scheduled background agents in Cursor, Google Antigravity, Claude Code, or Windsurf:

text
/mcp:memory-journal-mcp:optimize-journal mode="full" autoRun="true" limit="0"
/mcp:memory-journal-mcp:cms-rem-supervisor lookbackHours="24" autoRestore="true"

Complete Automations, Hooks & Cross-Client Scheduling Guide β†’

πŸ”§ Configuration

Environment Variables

VariableDescription
Core Database & Server
DB_PATHPath to the personal journal SQLite database (CLI: --db, --database, default: ./memory_journal.db)
DB_ENCRYPTION_KEYSQLCipher at-rest database encryption key (alias: MJ_DB_ENCRYPTION_KEY)
TEAM_DB_PATHPath to the shared team SQLite database (CLI: --team-db, --team-database)
TEAM_AUTHORDisplay name attached to team entries (used for local author identity; OAuth identity claims take precedence when creating team entries and RBAC ownership under active OAuth)
TEAM_DEFAULT_ROLEDefault RBAC role for unlisted team authors: admin, member, viewer, denied (CLI: --team-default-role, default: denied)
TEAM_ADMINBootstrap admin author name when the team_members table is empty (CLI: --team-admin)
ADDITIONAL_TEAM_DBSJSON map of label to absolute path for extra team databases searched by cross_team_search (CLI: --additional-team-dbs). Connections are read-write and team migrations are applied on open.
DEFAULT_WORKSPACE_IDDefault workspace ID for multi-tenant isolation (CLI: --default-workspace-id, default: default; MCP_WORKSPACE_ID provides a session-scoped schema-healing fallback on tool payloads)
MEMORY_JOURNAL_CONFIGPath to configuration file (.yaml, .yml, .json; CLI: --config)
LOG_LEVELServer log verbosity: debug, info, warning, error (CLI: --log-level, default: info)
INSTRUCTION_LEVELServer instruction verbosity: essential, detailed, or full (CLI: --instruction-level, default: detailed)
TRANSPORT / PORT / MCP_HOST / STATELESSTransport mode (stdio or http; CLI: --transport), HTTP port (--port, default: 3000), bind address (--server-host, fallback: HOST, default: localhost), and stateless HTTP mode (--stateless, default: false)
CORS_ORIGIN / MCP_CORS_ORIGIN / MCP_RATE_LIMIT_MAXAllowed CORS origins (--cors-origin) and per-IP/minute HTTP rate limit (default: 100)
GITHUB_TOKENPersonal access token for GitHub integrations
GITHUB_HOSTHostname used in constructed GitHub issue URLs (default: github.com; set for GitHub Enterprise)
DEFAULT_PROJECT_NUMBERDefault GitHub Project number for issue auto-assignment (CLI: --default-project)
PROJECT_REGISTRYJSON map of repo names to local paths and project numbers
EMBEDDING_MODELHuggingFace transformers model for semantic search (CLI: --embedding-model, default: Xenova/all-MiniLM-L6-v2)
EMBEDDING_CACHE_DIRDirectory for cached HuggingFace ONNX model weights (default: <dirname(DB_PATH)>/.cache/huggingface)
AUTO_REBUILD_INDEXRebuild vector search index on startup (true/false, CLI: --auto-rebuild-index)
Security & Tooling
ALLOWED_IO_ROOTSComma-separated paths for Code Mode and IO filesystem boundaries (fail-closed in stdio; mandatory when --transport http is used)
MEMORY_JOURNAL_MCP_TOOL_FILTERControl tool exposure (full, starter, essential, codemode, readonly, -github; CLI: --tool-filter, memory-journal.config.{yaml,yml,json} key: "toolFilter". TOOL_FILTER is not read by the filter parser)
CODE_MODE_MAX_RESULT_SIZEMax execution payload buffer size in Code Mode (bytes, default: 102400)
CODEMODE_INTERNAL_FULL_ACCESSAllow Code Mode to bypass tool filters internally (default: false)
MCP_AGENT_HEALINGEnable/disable autonomous tool & parameter healing (true/false, CLI: --no-agent-healing)
MAX_TOOL_INPUT_ELEMENTSMax array/object elements in tool inputs (default: 25000, 0 or Infinity = disabled)
MCP_AUTH_TOKEN / MCP_AUTH_SCOPESStatic Bearer authentication token (--auth-token, --auth-scopes) and comma-separated granted scopes for HTTP transport (default: read)
MCP_ENABLE_HSTS / TRUST_PROXYEnable Strict-Transport-Security header (--enable-hsts) and reverse-proxy X-Forwarded-For trust (--trust-proxy)
Briefing & Context
BRIEFING_ENTRY_COUNTNumber of granular journal entries in briefing (default: 3)
BRIEFING_SUMMARY_COUNTNumber of session summaries in briefing (default: 1)
BRIEFING_COMMIT_COUNTNumber of git commits in briefing (default: 3)
BRIEFING_IMPORTANCE_THRESHOLDMinimum importance score for briefing entries (default: 0.3)
BRIEFING_INCLUDE_TEAMInclude entries from the team database (default: false)
BRIEFING_GRAPHInclude relationship graph pivots & 14-day linkage hints in memory://briefing (default: true; disable via false or --no-briefing-graph)
BRIEFING_INSIGHTSInclude the Insights row (GitHub repo stats/traffic + analytics digest) in memory://briefing; false skips those API calls (default: true; disable via false or --no-briefing-insights)
BRIEFING_ISSUE_COUNT / BRIEFING_PR_COUNT / BRIEFING_PR_STATUSGitHub Issues (default: 0), PRs (default: 0), and PR status breakdown (default: false) in briefing
BRIEFING_MILESTONE_COUNTGitHub Milestones to list with titles (default: 3)
BRIEFING_WORKFLOW_COUNT / BRIEFING_WORKFLOW_STATUS / BRIEFING_COPILOT_REVIEWS (alias: BRIEFING_COPILOT)CI workflow runs (default: 0), status breakdown (default: false), and Copilot review state (default: false; BRIEFING_COPILOT_REVIEWS wins if both are set)
STALENESS_ACTIVE_HOURS / STALENESS_RECENT_DAYS / STALENESS_STALE_DAYSThresholds for memory://staleness project classification (defaults: 24h / 7d / 30d)
RULES_FILE_PATH / SKILLS_DIR_PATH / MEMORY_JOURNAL_WORKFLOW_SUMMARYInjected behavioral rules, skills index, and workflow summary (memory-journal.config.{yaml,yml,json} keys: "rulesFile", "skillsDir", "workflowSummary")
OAuth (HTTP Mode)
OAUTH_ENABLEDEnable OAuth 2.1 authentication (default: false)
OAUTH_ISSUER / OAUTH_AUDIENCE / OAUTH_JWKS_URI / OAUTH_CLOCK_TOLERANCE / PUBLIC_ORIGIN / OAUTH_ALLOW_PLAINTEXT_LOOPBACKOAuth token verification parameters (clock tolerance default: 60s), non-loopback RFC 9728 public origin (--public-origin), and local dev plaintext loopback issuer flag (--oauth-allow-plaintext-loopback)
Telemetry & Administration
AUDIT_LOG_PATH (fallback: MEMORY_JOURNAL_AUDIT_LOG) / AUDIT_REDACT / AUDIT_READS / AUDIT_LOG_MAX_SIZEPath to JSONL audit log file (or stderr), argument/result redaction, read-call logging, and rotation size limit (default: 10MB)
METRICS_EXPORT / PERSIST_METRICS / METRICS_PATH / MJ_METRICS_PORT / MJ_METRICS_HOSTPrometheus export (METRICS_EXPORT=prometheus auto-starts the standalone metrics server on 127.0.0.1:9465 in addition to mounting /metrics on the HTTP transport β€” skipped fail-closed when OAuth 2.1 is enabled without --auth-token/MCP_AUTH_TOKEN), disk-persisted metrics (--persist-metrics, --metrics-path), and dedicated scrape port/host
ARCHIVE_OLDER_THAN_DAYS / PRUNE_OLDER_THAN_DAYS / HARD_DELETE_OLDER_THAN_DAYS / PRUNE_IMPORTANCE_THRESHOLD / PRUNE_DRY_RUN / PRUNE_EXCLUDE_TAGSStartup lifecycle archiving and pruning (days default: 0 = disabled), importance threshold (default: 0.15), dry-run (default: false), and exclusion tags
DEBUG / DISABLE_ISSUE_LOGGINGAppend details.internal_message to structured formatHandlerError() payloads when DEBUG=true (use LOG_LEVEL=debug for verbose logging), and suppress automated runtime issue logging

GitHub Integration (Optional)

server.ts
export GITHUB_TOKEN="your_token"              # For Projects/Issues/PRs

Scopes: repo, project, read:org (org-level project discovery only)

Manage GitHub Seamlessly

Memory Journal provides a hybrid approach to GitHub management:

Capability SourcePurpose
MCP Servercreate_github_issue_with_entry, close_github_issue_with_entry, milestone create/update/delete, and Kanban moves
Agent (gh CLI)Merging pull requests and managing releases

MCP Server Tools (Read + Kanban + Milestones + Issue Lifecycle):

See the Complete tools reference for all supported GitHub integration capabilities, including query commands, Kanban management, milestone tracking, analytics, and issue lifecycle events.

Issue create and close are server tools: create_github_issue_with_entry and close_github_issue_with_entry, plus milestone create/update/delete and Kanban moves. Merging pull requests and managing releases stay with gh.

Complete GitHub integration guide β†’

Automate with GitHub Commander Workflows

The server natively bundles the memory-journal-mcp, datadog, and opentelemetry agent skills (served via SEP-2640 and memory://skills; datadog carries the Datadog dashboards/OpenMetrics integration guidance plus upstream dd-* sub-skills). It also provides built-in issue-commander, pr-commander, and cms-rem-supervisor MCP workflow prompts for autonomous DevOps stewardship: Issue Triage, Milestone Sprints, PR Reviews, Copilot Audits, Security Audits, Code Quality Audits, Performance Audits, Roadmap Kickoffs, and Dependency Updates. These workflows enforce multi-gate validation (lint, typecheck, test, and security checks) locally during agent tasks.

πŸ—οΈ Architecture

Data Flow

mermaid
flowchart TB
    AI["πŸ€– AI Agent<br/>(Cursor, Windsurf, Claude)"]

    subgraph MCP["MCP Server Capabilities"]
        direction LR
        Tools["πŸ› οΈ MCP Tools"]
        Resources["πŸ“‘ Resources"]
        Prompts["πŸ’¬ Prompts"]
    end

    subgraph Storage["Persistence Layer"]
        SQLite[("πŸ’Ύ SQLite<br/>Entries, Tags, Relationships")]
        Vector[("πŸ” Vector Index<br/>Semantic Embeddings")]
        Backups["πŸ“¦ Backups"]
    end

    subgraph External["External Integrations"]
        GitHub["πŸ™ GitHub API<br/>Issues, PRs, Actions"]
        Kanban["πŸ“‹ Projects v2<br/>Kanban Boards"]
    end

    AI <-->|"MCP Protocol"| MCP
    Tools --> Storage
    Tools --> External
    Resources --> Storage
    Resources --> External

Stack

Code
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ MCP Server Layer (TypeScript)                               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Tools           β”‚  β”‚ Resources       β”‚  β”‚ Prompts     β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Native SQLite Engine                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ better-sqlite3  β”‚  β”‚ sqlite-vec      β”‚  β”‚ transformersβ”‚  β”‚
β”‚  β”‚ (High-Perf I/O) β”‚  β”‚ (Vector Index)  β”‚  β”‚ (Embeddings)β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ SQLite Database with Hybrid Search                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ entries + tags + relationships + embeddings + backups   β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”§ Technical Highlights

Performance & Portability

  • TypeScript + Native SQLite - High-performance better-sqlite3 with synchronous I/O
  • sqlite-vec - Vector similarity search via SQLite extension
  • @huggingface/transformers - Local ML embedding models in JavaScript
  • Background Warmup - Model weights (~80–90MB fp32 ONNX weights) are loaded into memory asynchronously on server startup to avoid first-request latency. If the server is invoked before warmup completes, the first semantic search or vector insertion will incur a network-bound cold start (~1.5s - 3s) while the weights are cached locally.

Performance Benchmarks

Memory Journal is designed for extremely low overhead during AI task execution. We include a sequential vitest bench --run --no-file-parallelism suite (24 benchmarks across database, vector search, Code Mode sandbox, and MCP server routines) to maintain these baseline guarantees:

  • Database Operations (sqlite-adapter.bench.ts, post-seed ANALYZE): calculateImportance runs at ~4,194 ops/sec (~0.27ms mean) via a 256-entry LRU prepared statement cache. updateEntry executes at ~4,404 ops/sec (~0.55ms mean, ~0.32ms p75), getRecentEntries (limit 50) at ~2,676 ops/sec (~0.43ms mean; ~2,757 ops/sec scoped by workspace + project), getEntriesByIds (batch 50) at ~2,577 ops/sec (~0.45ms mean), createEntry at ~1,974 ops/sec (~0.78ms p75, ~1.33ms mean), and searchEntries (FTS5 BM25 + post-LIMIT batch importance hydration) at ~343 ops/sec (~3.11ms mean).
  • Vector Search Engine (vector-search.bench.ts, 1,000 indexed entries, post-seed ANALYZE): addEntry runs at ~5,355 ops/sec (~0.41ms mean, ~0.23ms p75) via sqlite-vec (vec0 with chunk_size=256), and k-NN similarity search with batch entry hydration runs at ~572 ops/sec (~1.87ms mean; ~331 ops/sec / ~3.16ms scoped by workspace + project).
  • Core MCP Routines (mcp-server.bench.ts): getTools uses cached O(1) dispatch (~8.87M ops/sec, ~0.0001ms; ~7.55M ops/sec filtered -team,-github via WeakMap cache). Full end-to-end callTool invocations (including interceptor, token estimation, and project registry resolution) run at ~1,380 ops/sec (~0.83ms) for get_recent_entries (~1,593 ops/sec / ~0.73ms with progressToken), ~2,145 ops/sec (~0.97ms mean, ~0.60ms p75) for create_entry, ~649 ops/sec (~2.62ms p75) for batch_create_entries (5 entries), and ~594 ops/sec (~1.89ms) for search_entries (rotating 8-term cache-miss workload).
  • Code Mode Sandbox (codemode-sandbox.bench.ts): getOrCreateCodemodeBundle (warm cache hit) runs at ~4.59M ops/sec (~0.0003ms), healCodeModeScript at ~488,200 ops/sec (~0.0023ms no-op fast path) / ~58,500 ops/sec (~0.020ms import rewrite), validateSandboxCode at ~190,000 ops/sec (~0.0058ms), callTool mj_execute_code (warm worker scalar) at ~353 ops/sec (~3.15ms), warm worker RPC at ~268 ops/sec (~4.23ms), and 4x concurrent burst at ~118 ops/sec (~9.40ms).

To run the benchmarking suite locally:

bash
pnpm run bench

Testing

Extensively tested across two frameworks:

SuiteCommandCovers
Vitest (unit/integration)pnpm testExtensive Vitest unit and integration suite with strict quality gates (database, tools, resources, handlers, security, GitHub, vector search, codemode)
Playwright (e2e)pnpm run test:e2eHTTP/SSE transport, auth, sessions, CORS, security headers
bash
pnpm test          # Unit + integration tests
pnpm run test:e2e  # End-to-end HTTP/SSE transport tests

Security

[!NOTE] When updating schemas or validation logic, follow Zod 4 Standard Schema and safe parsing best practices.

  • Deterministic error handling - Every tool returns structured {success, error, code, category, suggestion, recoverable} responses with actionable context β€” no raw exceptions, no silent failures, no misleading messages
  • Local-first - All data stored locally, no external API calls (except optional GitHub)
  • Input validation - Zod schemas, content size limits, SQL injection prevention, and <untrusted_remote_content> prompt-injection boundary tagging
  • Path traversal protection - ALLOWED_IO_ROOTS sandbox containment with URL-decode/symlink verification and backup path validation
  • Multi-tenant & filter enforcement - End-to-end workspace_id isolation across SQLite and Vector search, plus execution-layer --tool-filter enforcement across tools/call, Code Mode (mj.*), and fallback handlers
  • MCP 2025-11-25 annotations & icons - Behavioral hints (readOnlyHint, destructiveHint, etc.) and capability icons
  • HTTP transport hardening - OAuth 2.1 tokenClaims propagation, principal-bound stateful sessions (100 max active sessions), comprehensive security headers, configurable multi-origin CORS, 1MB body/stream limit, built-in per-IP rate limiting (100 req/min, keyed by SHA-256 of client IP), server timeouts, HSTS (opt-in), 30-min session timeout, and localhost-bound metrics (METRICS_EXPORT=prometheus automatically starts the standalone metrics server on 127.0.0.1:9465, customizable via MJ_METRICS_PORT and MJ_METRICS_HOST, in addition to mounting /metrics on the HTTP transport)
  • Token scrubbing - GitHub tokens and credentials automatically redacted from error and audit logs

Data & Privacy

  • Single SQLite file - You own your data
  • Portable - Move your .db file anywhere
  • Soft delete - Entries can be recovered
  • Auto-backup on restore - Never lose data accidentally

πŸ“š Documentation & Resources


πŸ“„ License

MIT License - See LICENSE file for details.

🀝 Contributing

Built by developers, for developers. PRs welcome! Ensure all unit and E2E tests, linting, and typechecks pass. See CONTRIBUTING.md for guidelines.

Upgrading from an earlier version? Your existing SQLite database is automatically migrated on startup.