Openclaw Fcma

Created By
MohitDhawane2 months ago
6-tier AI memory system with 28 MCP tools — episodic memory, knowledge graphs, document storage, session ledger, auth & GDP 6-tier AI memory system with 28 MCP tools — episodic memory, knowledge graphs, document storage, session ledger, auth & GDPR complianceR compliance
Overview

🧠 OpenClaw FCMA

The Memory Layer That Makes AI Actually Remember

Quick StartArchitectureToolsAPIContributing

Python MCP Tools License Tests


The Problem

Every time you start a new conversation with an AI, it forgets everything. Your name, your project, your preferences — all gone. You repeat yourself endlessly.

OpenClaw FCMA fixes this. It gives AI a persistent, structured memory — not just a bigger notepad, but a brain.

Architecture

┌─────────────────────────────────────────────────┐
│  L1 · Scratchpad  ·  Working Memory (this turn) │
├─────────────────────────────────────────────────┤
│  L2 · Journal     ·  Episodic Memory (FAISS)    │
├─────────────────────────────────────────────────┤
│  L3 · Mind        ·  Knowledge Graph (Neo4j)    │
├─────────────────────────────────────────────────┤
│  L4 · Library     ·  Your Documents (FAISS+SQL) │
├─────────────────────────────────────────────────┤
│  L5 · World State ·  Live Facts (Key-Value)     │
├─────────────────────────────────────────────────┤
│  L6 · Ledger      ·  Session Notes (.md files)  │
└─────────────────────────────────────────────────┘

vs. Traditional RAG:

FeatureRAGOpenClaw FCMA
StructureFlat vector search6-tier hierarchy
RelationshipsNoneKnowledge graph
LearningStaticSurprise-driven
DocumentsVector chaos at 25+ PDFsParent-child indexing
User isolationDIYBuilt-in
GDPRDIYBuilt-in export + delete

Quick Start

1. Install

git clone https://github.com/MohitDhawane/openclaw-fcma.git
cd openclaw-fcma
pip install -e ".[dev]"

2. Connect to Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "openclaw-fcma": {
      "command": "python",
      "args": ["-m", "openclaw.mcp_server"],
      "cwd": "/path/to/openclaw-fcma"
    }
  }
}

3. Restart Claude Desktop

That's it. Claude now has persistent memory with 28 tools.

4. Try It

You:    "Remember that my project uses Next.js 14 with PostgreSQL"
Claude: ✅ Stored in Journal + SQL. Total episodes: 1

--- [New conversation, days later] ---

You:    "What stack am I using?"
Claude: 🔍 Your project uses Next.js 14 with PostgreSQL.

28 MCP Tools

L2 Journal — Episodic Memory

ToolDescription
memory_storeStore a memory episode
memory_recallRecall relevant memories by query

L3 Mind — Knowledge Graph

ToolDescription
mind_add_nodeAdd concept/entity/action nodes
mind_add_edgeCreate relationships between nodes
mind_queryTraverse the knowledge graph
mind_decayApply forgetting curve (neural decay)
mind_pruneRemove low-weight forgotten nodes

L4 Library — Document Storage

ToolDescription
library_uploadUpload text documents
library_searchVector search across documents
library_ingestFull pipeline: chunk → embed → index
library_smart_searchTwo-stage retrieval with re-ranking

L5 World State — Live Facts

ToolDescription
world_state_setSet key-value pairs
world_state_getGet values by key

L6 Ledger — Session Summaries

ToolDescription
ledger_saveSave session summary as .md file
ledger_listList saved session notes
ledger_readRead a specific session file
ledger_contextGet recent context for session recovery

Discovery

ToolDescription
discovery_investigateAnalyze hollow-focus tokens

Knowledge Graph Viewer

ToolDescription
graph_viewView graph as markdown/mermaid/json/text
graph_exportExport graph to file on disk

User Management & Security

ToolDescription
user_registerCreate account with API key
user_data_exportExport all user data (GDPR)
user_data_deleteDelete all user data (GDPR)
db_statsDatabase statistics
audit_logView data sovereignty audit trail
auth_loginExchange API key for JWT token
auth_token_infoVerify and decode JWT token
auth_rate_statusCheck rate limit status

API Usage

from openclaw.memory.controller import MemoryController
from openclaw.memory.journal import Journal
from openclaw.memory.library import Library
from openclaw.memory.vector_store import FAISSVectorStore

# Initialize
journal = Journal(backend=FAISSVectorStore())
mc = MemoryController(l2_journal=journal)

# Store memory
mc.update_memory(
    query="User asked about Kubernetes",
    response="Kubernetes orchestrates containers...",
    surprise_score=0.85,
)

# Recall memory
context = mc.synthesize_context("Tell me about containers")

Data Storage

data/
├── openclaw.db          ← SQLite (users, audit, document index)
├── journal/             ← FAISS vectors (episodic memory)
├── library/             ← FAISS vectors (document search)
├── ledger/              ← Session summaries (.md files)
│   └── {user_id}/
│       ├── 2026-02-14_Database_Upgrade.md
│       └── 2026-02-15_API_Design.md
└── graph_exports/       ← Knowledge graph exports
    └── {user_id}/
        └── graph_2026-02-15.md

Security

  • JWT Authentication — 24-hour tokens with refresh and revocation
  • API Keys — Auto-generated per user (fcma_xxxx...)
  • Rate Limiting — Sliding window (60 req/min, configurable)
  • GDPR Compliance — Full data export + cascade deletion + audit trail
  • Password Hashing — Salted SHA-256

Environment Variables

VariableDefaultDescription
DATABASE_URLsqlite:///data/openclaw.dbDatabase connection string
FCMA_JWT_SECRETRandom (dev)JWT signing secret
FCMA_API_KEYNoneAPI key for server auth
FCMA_RATE_LIMIT60Requests per minute per user

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run MCP server (stdio)
python -m openclaw.mcp_server

# Run MCP server (HTTP)
python -m openclaw.mcp_server --transport http

# MCP Inspector (debug)
mcp dev openclaw/mcp_server.py

Project Structure

openclaw/
├── mcp_server.py           ← MCP server (28 tools, 4 resources)
├── database.py             ← SQL layer (SQLAlchemy)
├── auth.py                 ← JWT + rate limiting
├── memory/
│   ├── controller.py       ← Memory orchestrator
│   ├── journal.py          ← L2 episodic memory
│   ├── mind.py             ← L3 knowledge graph
│   ├── library.py          ← L4 document storage
│   ├── world_state.py      ← L5 key-value state
│   ├── context_ledger.py   ← L6 session summaries
│   ├── vector_store.py     ← FAISS backend
│   ├── graph_viewer.py     ← Graph export (4 formats)
│   ├── discovery.py        ← Curiosity-driven exploration
│   ├── salience.py         ← Surprise scoring
│   └── ingestion.py        ← Document chunking pipeline
└── tests/
    └── ...

Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Run tests (pytest tests/ -v)
  4. Commit your changes (git commit -m 'Add amazing feature')
  5. Push and open a Pull Request

License

MIT License — see LICENSE for details.


OpenClaw — Because AI should remember you.

Project Info
Created At
2 months ago
Updated At
2 months ago
Author Name
MohitDhawane
Star
-
Language
-
License
-
Category
Tags

Recommend Servers

View All