Skip to content
makalinPublic

About

Fragmenta is a lightweight, MCP-native memory engine that stores and retrieves contextual fragments across sessions. It uses deterministic scoring with recency, frequency, and importance to rank memory. Local-first, inspectable, and backend-agnostic (JSONL/SQLite), it turns interactions into structured, reusable context.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧩 Fragmenta

Fragmenta is a lightweight, MCP-native memory engine for AI systems.

It stores, scores, and retrieves contextual fragments (facts, preferences, interactions) across sessionsβ€”giving LLMs persistent, structured memory without black-box complexity.


πŸš€ Why Fragmenta?

LLMs forget everything between requests.

Fragmenta adds:

  • persistent memory
  • deterministic ranking
  • transparent storage
  • local-first control

✨ Features

  • 🧩 Fragment-Based Memory

    • Store atomic knowledge units
  • βš–οΈ Deterministic Ranking

    • Based on:

      • recency
      • frequency
      • importance
      • decay
  • πŸ” Context Retrieval

    • Query top relevant fragments instantly
  • πŸ”Œ MCP-Native

    • Works with Claude, Cursor, custom agents
  • πŸ’Ύ Pluggable Storage

    • JSONL (default)
    • SQLite
  • πŸ”Ž Inspectable

    • No hidden embeddings required

πŸ—οΈ Architecture

User Input β†’ Fragment Extractor β†’ Memory Store ↔ Scoring Engine β†’ Retrieval Engine β†’ LLM Context Injection


πŸ“¦ Installation

git clone https://github.com/makalin/fragmenta.git
cd fragmenta
npm install

⚑ Quick Start

npm run dev

βž• Store Memory

POST /memory

{
  "content": "User prefers minimal UI",
  "tags": ["preference", "ui"],
  "importance": 0.9
}

πŸ”Ž Query Memory

POST /query

{
  "query": "UI preference",
  "limit": 5
}

πŸ“š List Memory

GET /memory?tag=ui&search=minimal&limit=10

🧾 Memory Stats

GET /memory/stats

🧠 Fragment Schema

{
  "id": "uuid",
  "content": "User prefers minimal UI",
  "tags": ["preference"],
  "created_at": 1710000000,
  "last_accessed": 1710001000,
  "access_count": 3,
  "importance": 0.9
}

βš™οΈ Scoring Model

score =
  (importance * 0.4) +
  (recency * 0.3) +
  (frequency * 0.2) -
  (decay * 0.1)

Fully deterministic and tunable.


πŸ”Œ MCP Integration

{
  "mcpServers": {
    "fragmenta": {
      "command": "node",
      "args": ["dist/server.js"]
    }
  }
}

πŸ› οΈ Current Tools

HTTP API

  • POST /memory - store a fragment
  • POST /query - retrieve ranked fragments
  • GET /memory - list fragments with filters
  • GET /memory/:id - fetch one fragment
  • DELETE /memory/:id - delete one fragment
  • GET /memory/stats - aggregate memory statistics
  • GET /health - health check

MCP Tools

  • store_memory
  • query_memory
  • list_memories
  • get_memory
  • delete_memory
  • memory_stats

πŸ“ Project Structure

fragmenta/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ server/
β”‚   β”‚   β”œβ”€β”€ mcp.ts
β”‚   β”‚   β”œβ”€β”€ api.ts
β”‚   β”‚   └── routes/
β”‚   β”‚
β”‚   β”œβ”€β”€ memory/
β”‚   β”‚   β”œβ”€β”€ fragment.ts
β”‚   β”‚   β”œβ”€β”€ store.ts
β”‚   β”‚   └── schema.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ scoring/
β”‚   β”‚   β”œβ”€β”€ score.ts
β”‚   β”‚   β”œβ”€β”€ decay.ts
β”‚   β”‚   └── rank.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ retrieval/
β”‚   β”‚   β”œβ”€β”€ query.ts
β”‚   β”‚   └── filter.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ storage/
β”‚   β”‚   β”œβ”€β”€ jsonl.ts
β”‚   β”‚   β”œβ”€β”€ sqlite.ts
β”‚   β”‚   └── adapter.ts
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ time.ts
β”‚   β”‚   └── logger.ts
β”‚   β”‚
β”‚   └── index.ts
β”‚
β”œβ”€β”€ data/
β”‚   └── memory.jsonl
β”‚
β”œβ”€β”€ config/
β”‚   └── default.json
β”‚
β”œβ”€β”€ tests/
β”‚
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

🧩 Roadmap

Primary Backend Direction

  • Velo-Lite backend as the scalable production backend
  • Velo-Lite backend with multi-agent shared memory
  • Velo-Lite namespaces for agent, team, and tenant isolation
  • Velo-Lite shared channels for cross-agent context exchange
  • Velo-Lite write conflict resolution and optimistic concurrency
  • Velo-Lite replication, backup, and recovery workflows

Next Tools And Functions

  • update_memory tool and PATCH /memory/:id
  • bulk_store_memories for batched ingestion
  • bulk_delete_memories for cleanup jobs
  • search_by_tags shortcut tool
  • export_memories to JSON/JSONL
  • import_memories from JSON/JSONL
  • pin_memory or protected fragments
  • archive_memory and soft-delete support
  • memory_timeline for chronological inspection
  • memory_explain to show score breakdown per fragment

Retrieval Improvements

  • Semantic search (optional embeddings)
  • Hybrid lexical + semantic ranking
  • Better exact-match and phrase-match scoring
  • Per-tag weighting and query boosting
  • Configurable decay strategies
  • Deduplication and fragment merging

Storage And Reliability

  • Default SQLite mode for safer concurrent writes
  • Storage migrations and schema versioning
  • Snapshot and backup support
  • File locking for JSONL mode
  • Background compaction and repair tools

Security And Operations

  • API auth token support
  • Rate limiting
  • Request audit logging
  • CORS and host allowlist controls
  • Configurable request size limits
  • Safer production defaults

Developer Experience

  • CLI tool
  • Visualization UI
  • OpenAPI spec for the HTTP API
  • More integration and concurrency tests
  • Docker image and compose setup
  • Benchmark suite

Multi-Agent Memory

  • Multi-agent shared memory
  • Agent namespaces and tenant isolation
  • Shared memory rooms or channels
  • Agent attribution on fragments
  • Conflict resolution for concurrent writes
  • Cross-agent memory permissions

πŸ”’ Philosophy

  • Local-first
  • Transparent > magical
  • Deterministic > probabilistic
  • Simple > complex

πŸ“„ License

MIT

About

Fragmenta is a lightweight, MCP-native memory engine that stores and retrieves contextual fragments across sessions. It uses deterministic scoring with recency, frequency, and importance to rank memory. Local-first, inspectable, and backend-agnostic (JSONL/SQLite), it turns interactions into structured, reusable context.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages