Skip to main content
Glama

CML v3 — Cognitive Memory Layer for LLM Agents

A production-ready MCP memory server that productionizes the mathematical foundations introduced in SLM-V3 (Bhardwaj, 2026), delivering them with a novel Memory Feed presentation format and comprehensive benchmark evaluation.

CML v3 builds on three mathematical frameworks from SLM-V3:

  • Fisher-Rao geodesic distance for embedding similarity (replacing cosine similarity)

  • Sheaf cohomology for topical coherence detection

  • Langevin dynamics on Poincare ball for memory lifecycle (natural reinforcement and forgetting)

Features

  • 4-channel retrieval: Semantic + BM25 + Entity Graph + Temporal, fused with Reciprocal Rank Fusion

  • Memory Feed: SNS-inspired presentation with trajectory tracking, causal chains, and retrieval reasons

  • Bayesian trust scoring: Beta distribution (alpha/beta) for memory reliability

  • Fully local: SQLite storage, no cloud dependencies required

  • MCP protocol: Works with Claude Code, Claude Desktop, and any MCP-compatible client

Related MCP server: OwnMemory

Quick Start

Install

pip install cml-v3

# For Gemini embeddings (recommended, requires API key):
pip install cml-v3[gemini]

# For fully offline operation (sentence-transformers):
pip install cml-v3[local]

# Everything:
pip install cml-v3[all]

Run the MCP Server

# With Gemini embeddings (set API key first):
export GEMINI_API_KEY="your-key-here"
cml-v3-server

# With local embeddings (no API key needed):
CML_V3_EMBEDDING_PROVIDER=local cml-v3-server

Configure in Claude Code

Add to ~/.claude/settings.json:

{
  "mcpServers": {
    "cml-v3-memory": {
      "command": "cml-v3-server",
      "env": {
        "GEMINI_API_KEY": "your-key-here"
      }
    }
  }
}

Configure in Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "cml-v3-memory": {
      "command": "python",
      "args": ["-m", "cml_v3.server"],
      "env": {
        "GEMINI_API_KEY": "your-key-here"
      }
    }
  }
}

MCP Tools

CML v3 provides 4 consolidated tools (optimized for minimal context token usage):

Search long-term memory with multi-channel retrieval.

Action

Description

search

Multi-channel search with Memory Feed format

prime

Session-start briefing (formatted context)

recall

Deep search with entity graph expansion

timeline

Chronological memory listing

memory_store

Write to long-term memory with contradiction detection.

Action

Description

store

Save new fact (auto-embeds, checks contradictions)

reinforce

Strengthen existing memory (trust alpha += 1)

forget

Archive a memory (move to ARCHIVED zone)

memory_manage

Memory system administration.

Action

Description

stats

Zone/project statistics

contradictions

List detected contradictions

graph

Explore entity knowledge graph

memory_system

Infrastructure health and configuration.

Action

Description

health

Component status check

evolve

Run Langevin dynamics evolution step

config

View/update configuration

Memory Feed Format

Search results are returned as enriched feeds (not flat lists):

{
  "id": "sm-abc123",
  "content": "The project deadline was moved to April.",
  "trajectory": "strengthening",
  "confidence_rank": "high",
  "trust_score": 0.85,
  "shared_entities": ["Project X", "April deadline"],
  "related_to": ["sm-def456", "sm-ghi789"],
  "thread": [{"from": "sm-def456", "type": "led_to"}],
  "retrieval_reason": "semantic similarity + entity(Project X)",
  "contradictions": []
}

Mathematical Foundations

The following mathematical modules are ported from SLM-V3 (MIT License).

Fisher-Rao Geodesic Distance

Instead of cosine similarity, CML v3 uses the Fisher-Rao geodesic distance on diagonal Gaussian manifolds, respecting per-dimension confidence:

$$d_{FR}(\mathbf{u}, \mathbf{v}) = \sqrt{\sum_i \frac{(u_i - v_i)^2}{\frac{1}{2}(\sigma_{u,i}^2 + \sigma_{v,i}^2)}}$$

Sheaf Cohomology for Topical Coherence

Memories connected by shared entities form a cellular sheaf. The coboundary operator detects topical anomalies with mathematical guarantees (note: effective for topical coherence, not factual contradiction — see our paper for details):

$$(\delta_0 \mathbf{x})(e_{uv}) = \mathcal{F}_{u \trianglelefteq e}(\mathbf{x}u) - \mathcal{F}{v \trianglelefteq e}(\mathbf{x}_v)$$

Langevin Dynamics on Poincare Ball

Memory lifecycle is modeled as a stochastic process on the Poincare ball, where the origin represents high importance and the boundary represents forgetting:

Zone

Radius

Semantics

ACTIVE

[0, 0.3)

Core memories

WARM

[0.3, 0.55)

Recently relevant

COLD

[0.55, 0.8)

Fading

ARCHIVED

[0.8, 1.0)

Effectively forgotten

Data Storage

All data is stored locally in ~/.cml-v3/memory.db (SQLite). Override with:

export CML_V3_DATA_DIR=/path/to/custom/dir

Development

git clone https://github.com/Haratakeshi/cml-v3.git
cd cml-v3
pip install -e ".[dev,all]"
pytest tests/

Citation

If you use CML v3 in your research, please cite:

@article{fujiwara2026cmlv3,
  title={Memory Feed: Productionizing Mathematical Memory Foundations
         for LLM Agents via MCP},
  author={Fujiwara, Takeshi},
  journal={arXiv preprint},
  year={2026}
}

License

MIT License. See LICENSE.

Acknowledgments

The mathematical foundations (Fisher-Rao distance, sheaf cohomology, Langevin dynamics on Poincare ball) are ported from SLM-V3 by Varun Pratap Bhardwaj under the MIT license. We thank the author for releasing these foundational models.

CML v3 was co-developed with Claude (Anthropic).

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to persist facts with tags, sources, and importance in a local SQLite database, retrieve them through hybrid BM25 plus embedding search weighted by retention decay, link or supersede related entries, and review everything in a read-only visual dashboard showing the memory graph and timeline.
      6
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to save, recall, and forget persistent memories stored entirely on the local machine in SQLite, using hybrid semantic and keyword search with on-device embeddings, plus spaces and profile context injection.
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables AI assistants to retain atomic facts, decisions, and episodic lessons in a persistent shared SQLite graph memory, then recall them through hybrid BM25 plus dense-vector search with spreading activation and progressively packed context. Also supports reflection-based belief revision so stale or contradictory memories are superseded rather than returned alongside current ones.
      4
      18 PyPI
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables agents to persist, search, and consolidate durable cross-session memory through a dual-vault SQLite/FTS5 store with hybrid reranking, retrieval gating, temporal relations, and Markdown wiki projection.
      MIT