Skip to main content
Glama

🏛️ Manthan Blueprint (@kidakaka/manthan-mcp)

Commercial-Grade, Git-Native, Deterministic Memory Engine for AI Agents via Model Context Protocol (MCP)

npm version npm downloads TypeScript Node.js MCP License Sponsor

Unlike probabilistic vector-only memory layers that suffer from black-box semantic drift and silent hallucinations, Manthan treats agent memory as version-controlled state ("Memory-as-Code").

  • Git is the Single Source of Truth: Every state update, architectural decision, and session handoff is an atomic Git commit with full author-agent and observability trace metadata.

  • Embedded SQLite FTS5 Sidecar Index: Uses Node's built-in node:sqlite (DatabaseSync with BM25 ranking) for sub-5ms deterministic lexical retrieval with zero native C++ compilation dependencies on Windows, Linux, and macOS.

  • Git Commit SHA Provenance: Every memory recall operation returns cryptographic commit SHA provenance, providing reproducible time-travel and compliance auditing.

IMPORTANT

📢 Calling Early Adopters & Agent Builders!

We need real-world user feedback more than code contributions right now.
If you are building with Claude Code, Cursor, Windsurf, or Google Antigravity, we want your feedback: Does deterministic Git-backed memory eliminate the state drift and hallucinations you experience with probabilistic vector stores?
👉 Read our Early Adopter & Contributor Guide | 💬 Join GitHub Discussions


System Overview

Manthan is an open-source, deterministic, Git-native memory engine for AI coding agents exposed through the Model Context Protocol (MCP). It stores agent memories as structured Markdown artifacts with strict YAML frontmatter, archives historical state transitions via atomic Git commits, and provides sub-5ms BM25 lexical recall via an embedded SQLite FTS5 sidecar index (node:sqlite).

workspace/
├── .manthan.yaml               # Declarative engine configuration
└── .manthan/
    ├── index.db                # Ephemeral SQLite FTS5 BM25 search sidecar (gitignored)
    └── memory/
        ├── working/            # Active mutable memory (Read/Write)
        │   └── backend/
        │       └── mem_01j9x8.md
        └── constitution/       # Architectural guardrails & ADRs (Read-only)
            └── core/
                └── ADR-001.md

Architectural Tiers:

  1. Active Memory Store (working Layer): Stores live project state, episodic session decisions, and task handoffs. Validated against a strict Zod schema with atomic Git commits.

  2. Constitutional Memory (constitution Layer): Stores non-negotiable architectural rules, ADRs, and project conventions inside .manthan/memory/constitution/. Proposed additions default to status: draft for human review.


Related MCP server: openmemkit

Subdirectories & System Boundaries

  • Core Application & Server Runtime (src) - Wires configuration, storage sub-engines, MCP resources, and tools into a unified ManthanContext. Exposes Commander CLI and Stdio MCP runtime.

    • Configuration & Client Linker (src/config) - Zod schema validation for .manthan.yaml, frontmatter normalization, and automated client configuration injection for Claude Desktop, Cursor, and VS Code.

    • Resources Provider (src/resources) - Direct MCP resource endpoints (manthan://constitution, manthan://active-context, manthan://status) for zero-turn context injection.

    • Storage Engine (src/storage) - Dual-tier persistence through GitEngine (commits, lineage, branches), MarkdownStore (filesystem YAML/MD), and SqliteIndexer (embedded FTS5 BM25).

    • MCP Tools Implementation (src/tools) - Handlers for recall_memory, commit_memory, propose_constitution_rule, audit_memory_lineage, sync_memory_index, and fetch_by_tags_and_keywords.


Global Invariants

  • Memory-as-Code Integrity: All persistent memory artifacts must reside as .md files with valid YAML frontmatter matching MemoryFrontmatterSchema.

  • Constitutional Immutability: Memories under layer: "constitution" are read-only during standard agent task execution; new rules are submitted via propose_constitution_rule with layer: 'constitution' and status: 'draft'.

  • Deterministic Lexical Retrieval: Search queries execute against SQLite FTS5 BM25 index with fixed column weights (title: 5.0, tags: 3.0, namespace: 2.0, content: 1.0), preventing non-deterministic vector drift.

  • StdIO Protocol Separation: Standard output (stdout) is strictly reserved for JSON-RPC transport frames. All logging, diagnostic outputs, and notices must be written to standard error (stderr).

  • Startup Index Resynchronization: If the cached git_head_sha in the SQLite database does not match the active Git HEAD SHA during server startup, a full index rebuild from disk is automatically performed.


Global Side Effects

  • Local Filesystem: Creates and modifies files in .manthan/memory/working/ and .manthan/memory/constitution/. May generate or modify .manthan.yaml and .gitignore.

  • Embedded Database: Creates and manages .manthan/index.db SQLite database using WAL mode (PRAGMA journal_mode = WAL).

  • Git Version Control: Executes Git commands via simple-git: repository initialization, file staging, atomic commits with author metadata "${author_agent} <agent@manthan.internal>", and branch creation (manthan/rule-${id}).

  • Host Client Configuration: Modifies client configuration files during link or init (Claude Desktop config in OS AppData/Config, .cursor/mcp.json, and .vscode/mcp.json).


System Verification

  • Run: npm test


🌊 The Origin & Etymology of "Manthan" (मंथन)

"Out of the turbulent ocean of chaotic noise, deep contemplation churns the immortal nectar of truth."

Manthan (मन्थन) is an ancient Sanskrit word originating from the root manth (मन्थ्), which translates to "to churn, vigorously agitate, deeply contemplate, and extract the concentrated essence from vast substance."

In Indian philosophy and classical Vedic epics (such as the Mahabharata and Bhagavata Purana), the term finds its definitive mythic expression in Samudra Manthan (समुद्र मन्थन — The Churning of the Cosmic Ocean). When the forces of light (Devas) and darkness (Asuras) churned the primordial ocean of chaos, they churned through the deadly, volatile poisons (Halahala) to extract the supreme divine treasures (Ratnas) and the ultimate prize: Amrita (अमृत) — the immortal nectar of eternal life, truth, and absolute clarity.

Why Was This Name Chosen for This Engine?

In modern software engineering with autonomous AI agents, models operate inside a vast, turbulent, and noisy ocean of ephemeral tokens, fleeting scratchpads, and probabilistic hallucinations:

  1. Churning the Ocean of Ephemeral Context:
    During real-world development, AI agents generate tens of thousands of tokens of intermediate trial-and-error, debug outputs, and transient hypotheses. If left uncurated, this context degrades into token exhaustion, context drift, and silent hallucinations. Manthan acts as the cognitive churning rod — actively stirring through this raw stream, discarding the volatile noise, and distilling the essential truths of your codebase.

  2. From Fleeting Noise to Immortal State (Amrita):
    In Indian thought, Amrita is that which cannot die (a-mrita = deathless). When an agent commits an architectural decision or constitutional rule in Manthan, it is not lost when a context window closes or an LLM session restarts. It is forged into an immutable, cryptographically signed Git commit backed by sub-5ms BM25 retrieval — conferring permanence, reproducibility, and time-travel lineage upon the agent's memory.

  3. Contemplative Cognition (Manan):
    Manthan is intimately linked to the Sanskrit concept of Manan (मनन) — rigorous intellectual contemplation, inner reflection, and conscious discernment. Rather than treating memory as an opaque, black-box vector database that drifts unpredictably, Manthan treats memory as version-controlled state ("Memory-as-Code") that humans and agents can consciously audit, debate, and evolve.


📋 Standardized Memory Artifact Schema

Every memory artifact is stored as a standard .md file with strict YAML frontmatter:

---
id: "mem_01j9x8k2m"
title: "API Idempotency Key Header Standard"
layer: "working" # "working" | "constitution"
namespace: "backend/payments" # Logical topic or directory slug
status: "active" # "active" | "superseded" | "draft" | "archived"
author_agent: "claude-code"
trace_id: "tr_98234792"
supersedes: null # Optional ID of previous memory artifact
tags: ["idempotency", "api", "payments"]
updated_at: "2026-11-09T10:00:00.000Z"
---

## Context & Decision
All payment mutation endpoints must accept and validate a unique `Idempotency-Key` header.

🛠️ MCP Tools Specification

Manthan exposes 6 deterministic tools to any MCP-compliant client:

Tool

Purpose

Key Inputs

Key Outputs

recall_memory

Lexical BM25 search across state & guardrails

query, namespace, tags, include_constitution, limit

JSON bundle of constitution_rules & working_memories with Git commit SHAs

commit_memory

Atomic state write with Git commit & FTS indexing

namespace, title, content, tags, author_agent, trace_id, supersedes_id

Commit SHA, artifact path, and confirmation

propose_constitution_rule

Propose architectural law or ADR for review

title, content, namespace, rationale, author_agent, source_memory_id

Draft artifact path and human review guidance

audit_memory_lineage

Provenance audit and time-travel history

memory_id or file_path, max_commits

Chronological commit history, agent author, and diff summary

sync_memory_index

Sidecar index maintenance & cache refresh

force_rebuild

Indexed counts, duration, and synchronized Git HEAD SHA

fetch_by_tags_and_keywords

Tag-filtered BM25 retrieval with snippet extraction

tags, tag_mode, keywords, doc_type, trust_tier, limit, snippets

Compact excerpt list and OKF v0.2 matching documents


📦 Native MCP Resources (manthan://...)

Manthan exposes live MCP Resources that clients (Claude, Cursor, Antigravity) can read directly into their context window without burning a tool turn:

URI

Type

Purpose

Content

manthan://constitution

text/markdown

Zero-turn guardrail injection

Active architectural rules & ADRs

manthan://active-context

text/markdown

Active working context snapshot

Active episodic memories & handoffs

manthan://status

application/json

Telemetry & engine health

Memory counts, Git HEAD SHA & BM25 config


⚙️ Declarative Configuration (.manthan.yaml)

version: "1.0"
project: "my-project"

storage:
  root_dir: ".manthan/memory"
  working_dir: ".manthan/memory/working"
  constitution_dir: ".manthan/memory/constitution"
  index_db_path: ".manthan/index.db"

git:
  auto_commit: true
  branch_strategy: "direct" # "direct" | "session-branch"
  commit_prefix: "chore(manthan):"

governance:
  prioritize_constitution_on_recall: true
  allow_direct_constitution_writes: false

retrieval:
  bm25_weights:
    title: 5.0      # Boost title matches 5x
    tags: 3.0       # Boost tag matches 3x
    namespace: 2.0  # Boost namespace matches 2x
    content: 1.0    # Base content body weight

🚀 Quickstart & Frictionless Setup

💡 Zero Background Daemons Needed!
Unlike traditional servers, you never need to keep a terminal open running manthan serve. Your LLM client (Cursor, Claude Desktop, VS Code) launches Manthan automatically in the background as an isolated sidecar process over stdio.

1. Initialize Manthan in your repository

npx @kidakaka/manthan-mcp init

This automatically:

  • Creates .manthan.yaml with declarative settings.

  • Creates directory structures for working and constitution memories.

  • Adds .manthan/index.db* to .gitignore.

  • Initializes Git (if not already initialized).

  • Seeds initial constitutional rules (ADR-001) and working memories.

  • Builds the local SQLite FTS5 search index.

  • Auto-configures Cursor & VS Code: Generates .cursor/mcp.json and .vscode/mcp.json in your repository so you can start immediately with zero manual configuration!

To automatically connect Claude Desktop without touching JSON files or hunting down OS appdata paths:

npx @kidakaka/manthan-mcp link claude

(You can also run npx @kidakaka/manthan-mcp link all to configure all detected LLM clients at once).

3. Inspect Status

npx @kidakaka/manthan-mcp status

🔌 Manual Client Integration (Optional)

If you prefer to configure your client manually, add the following to your client's settings:

1. Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "manthan": {
      "command": "npx",
      "args": ["-y", "@kidakaka/manthan-mcp", "serve"]
    }
  }
}

2. Cursor

In .cursor/mcp.json (already generated automatically by manthan init):

{
  "mcpServers": {
    "manthan": {
      "command": "npx",
      "args": ["-y", "@kidakaka/manthan-mcp", "serve"]
    }
  }
}

3. VS Code / Copilot / Cline

In .vscode/mcp.json (already generated automatically by manthan init):

{
  "mcpServers": {
    "manthan": {
      "command": "npx",
      "args": ["-y", "@kidakaka/manthan-mcp", "serve"]
    }
  }
}

4. Google Antigravity

Add to your Antigravity MCP configuration (~/.gemini/antigravity/mcp/manthan.json or config.json):

{
  "name": "manthan",
  "command": "npx",
  "args": ["-y", "@kidakaka/manthan-mcp", "serve"]
}

💻 CLI Commands Reference

  • manthan init [--dir <path>] [-c <client>]: Initialize memory storage, seed artifacts, and generate client configs.

  • manthan link [claude|cursor|vscode|all]: Automatically link the MCP server into your LLM client configuration.

  • manthan serve [--dir <path>]: Start the MCP server over stdio (called automatically by LLM clients).

  • manthan status [--dir <path>]: View memory counts, Git HEAD, and index health.

  • manthan reindex [--dir <path>]: Force a complete rebuild of the SQLite FTS5 index.


🧪 Testing

Run the automated end-to-end integration test suite:

npm test

The test verifies:

  1. Workspace initialization and Git repository detection.

  2. Atomic commit_memory execution and Git SHA stamping.

  3. Sub-5ms BM25 lexical recall with recall_memory.

  4. State supersession (marking v1 as superseded, creating v2 as active, excluding superseded items from recall).

  5. Constitutional rule proposal and staging with status: draft.

  6. Audit lineage retrieval via Git commit logs.

  7. Full FTS5 sidecar index rebuilding and HEAD SHA synchronization.


🤝 Contributing & Early Feedback

We value real-world feedback from early adopters above everything else.

  • If you are an agent developer or user: Test Manthan in your repository and tell us what works, what breaks, and how your agent behaves with deterministic state handoffs.

  • If you are a systems/TypeScript engineer: Help us expand MCP client presets, optimize BM25 tokenizers, and build multi-repo memory federation.

Please check out our Contributing Guide and Project Roadmap & TODO for our complete publishing checklist, discussion links, and local development instructions.


💖 Sponsorship & Support

If Manthan helps eliminate hallucination and state drift in your AI agents, consider supporting ongoing open-source maintenance via GitHub Sponsors.


📄 License

Licensed under the Apache License, Version 2.0 (the "License").
You may not use this software except in compliance with the License.

Copyright © 2026 Prasad Ajinkya and Manthan Contributors.

Available Tools

6 tools
audit_memory_lineageB

Provenance & Time-Travel: retrieves chronological Git commit history, agent author metadata, and diff audit trail for a memory artifact.

Inputs: file_path, memory_id, max_commits.

commit_memoryB

Deterministic state write: validates Markdown frontmatter, atomically commits to Git with agent provenance, and updates local FTS5 index.

Inputs: title (required), content (required), namespace (required), author_agent (required), +6 more.

fetch_by_tags_and_keywordsB

Specialized harness to fetch, filter, and rank memories via multi-tag combinations (AND/OR) and BM25 lexical keywords with snippet context extraction.

Inputs: tags, limit, doc_type, keywords, +5 more.

propose_constitution_ruleB

Guardrail Promotion: proposes a new architectural law or ADR inside constitution memory with status: "draft" for human developer review.

Inputs: title (required), content (required), namespace (required), rationale (required), +4 more.

recall_memoryB

Lexical BM25 search across agent working memory and constitutional guardrails with Git commit SHA provenance and glob namespace filtering.

Inputs: tags, limit, query, namespace, +2 more.

sync_memory_indexB

Sidecar Maintenance: scans .manthan/memory/, parses Markdown frontmatter, synchronizes the SQLite FTS5 index, and stamps the current Git commit SHA.

Inputs: force_rebuild.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 6 tools

    Disambiguation3/5

    recall_memory and fetch_by_tags_and_keywords both perform BM25 lexical retrieval over memories, differing mainly in glob namespace filtering versus multi-tag combinations and snippet extraction, so an agent may hesitate between them. The other four tools—commit, sync, audit, and propose—are clearly distinct.

    Naming Consistency4/5

    All names use snake_case with a verb-first pattern, giving a predictable style throughout. Minor deviations are the long compound names like audit_memory_lineage and fetch_by_tags_and_keywords, but no conventions are mixed.

    Tool Count5/5

    Six tools is well-scoped for a memory/provenance server, with each tool covering a distinct phase: retrieval, audit, index maintenance, write, and constitution proposal. There are no obvious filler tools.

    Completeness3/5

    The set covers search, commit, index sync, lineage audit, and rule proposal, but there is no explicit delete/forget or update-existing-memory operation. Constitution rules can be proposed as drafts but cannot be approved, rejected, or promoted, creating a lifecycle dead end.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides long-lived, cross-project technical memory for AI agents via markdown cards stored in git and indexed by SQLite, enabling search, retrieval, and human-reviewed knowledge management.
      ISC
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to maintain a persistent, queryable memory stored as user-owned Markdown files, with dual-channel retrieval (FTS5 and optional semantic search) and an audited write pipeline.
      11
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents like Codex, Grok Build, and Antigravity to share persistent local memory, preferences, project context, tasks, and handoffs using Markdown and SQLite.
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI coding agents to persist atomic, token-budgeted facts across sessions via SQLite-backed full-text search, automatically superseding outdated entries and flagging memories as stale when Git webhooks detect changes to anchored repo files.
      11
      AGPL 3.0