Labsco
alibaizhanov logo

Mengram

β˜… 181

from alibaizhanov

Human-like memory layer for AI agents with semantic, episodic, and procedural memory types, cognitive profiling, knowledge graph, and 12 MCP tools.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredAdvanced setup
<div align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/Mengram-a855f7?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAgMTIwIj48cGF0aCBkPSJNNjAgMTYgUTkyIDE2IDk2IDQ4IFExMDAgNzggNzIgODggUTUwIDk2IDM4IDc2IFEyNiA1OCA0NiA0NiBRNjIgMzggNzAgNTIgUTc2IDY0IDYyIDY4IiBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS13aWR0aD0iOCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PGNpcmNsZSBjeD0iNjIiIGN5PSI2OCIgcj0iOCIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg=="> <img alt="Mengram" src="https://img.shields.io/badge/Mengram-a855f7?style=for-the-badge&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjAgMTIwIj48cGF0aCBkPSJNNjAgMTYgUTkyIDE2IDk2IDQ4IFExMDAgNzggNzIgODggUTUwIDk2IDM4IDc2IFEyNiA1OCA0NiA0NiBRNjIgMzggNzAgNTIgUTc2IDY0IDYyIDY4IiBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS13aWR0aD0iOCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PGNpcmNsZSBjeD0iNjIiIGN5PSI2OCIgcj0iOCIgZmlsbD0iI2ZmZiIvPjwvc3ZnPg=="> </picture>

Give your AI agents memory that actually learns

GitHub stars PyPI npm License: Apache 2.0 PyPI Downloads Last commit

Website Β· Get API Key Β· Docs Β· Console Β· Examples

</div>
Copy & paste β€” that's it
pip install mengram-ai   # or: npm install mengram-ai
Copy & paste β€” that's it
from mengram import Mengram
m = Mengram(api_key="om-...")           # Free key β†’ mengram.io

m.add([{"role": "user", "content": "I use Python and deploy to Railway"}])
m.search("tech stack")                  # β†’ facts
m.ask("what's my tech stack?")          # β†’ synthesized answer + citations
m.episodes(query="deployment")          # β†’ events
m.procedures(query="deploy")            # β†’ workflows that evolve from failures

Native multilingual: ask in Russian, Chinese, Spanish, Japanese β€” Mengram retrieves and answers across 23 languages (Cohere multilingual embeddings + rerank).


Claude Code β€” Zero-Config Memory

Two commands. Claude Code remembers everything across sessions automatically.

Copy & paste β€” that's it
pip install mengram-ai
mengram setup              # Sign up + install hooks (interactive)

Or manually: export MENGRAM_API_KEY=om-... β†’ mengram hook install

What happens:

Copy & paste β€” that's it
Session Start  β†’  Loads your cognitive profile (who you are, preferences, tech stack)
Every Prompt   β†’  Searches past sessions for relevant context (auto-recall)
After Response β†’  Saves new knowledge in background (auto-save)

No manual saves. No tool calls. Claude just knows what you worked on yesterday.

Copy & paste β€” that's it
mengram hook status     # check what's installed
mengram hook uninstall  # remove all hooks

Why Mengram?

Every AI memory tool stores facts. Mengram stores 3 types of memory β€” and procedures evolve when they fail.

Mengramclaude-memMem0ZepLetta
Semantic memory (facts, preferences)YesYesYesYesYes
Episodic memory (events, decisions)YesPartialNoNoPartial
Procedural memory (workflows)YesNoNoNoNo
Procedures evolve from failuresYesNoNoNoNo
Cognitive ProfileYesNoNoNoNo
Native multilingual (23 languages)YesNoNoNoNo
Ask & Citations (synthesized answer)YesNoNoNoNo
Multi-user isolationYesNoYesYesNo
Knowledge graphYesNoYesYesYes
Claude Code hooks (auto-save/recall)YesYesNoNoNo
LangChain + CrewAI + MCPYesNoPartialPartialPartial
Import ChatGPT / ObsidianYesNoNoNoNo
PricingFree tierFree / OSS$19-249/moEnterpriseSelf-host

Get Started in 30 Seconds

1. Install

Copy & paste β€” that's it
pip install mengram-ai

2. Setup (creates account + installs Claude Code hooks)

Copy & paste β€” that's it
mengram setup

Or get a key manually at mengram.io and export MENGRAM_API_KEY=om-...

3. Use

Copy & paste β€” that's it
from mengram import Mengram

m = Mengram(api_key="om-...")

# Add a conversation β€” auto-extracts facts, events, and workflows
m.add([
    {"role": "user", "content": "Deployed to Railway today. Build passed but forgot migrations β€” DB crashed. Fixed by adding a pre-deploy check."},
])

# Search across all 3 memory types at once
results = m.search_all("deployment issues")
# β†’ {semantic: [...], episodic: [...], procedural: [...]}
<details> <summary><b>File Upload (PDF, DOCX, TXT, MD)</b></summary>
Copy & paste β€” that's it
# Upload a PDF β€” auto-extracts memories using vision AI
result = m.add_file("meeting-notes.pdf")
# β†’ {"status": "accepted", "job_id": "job-...", "page_count": 12}

# Poll for completion
m.job_status(result["job_id"])
Copy & paste β€” that's it
// Node.js β€” pass a file path
await m.addFile('./report.pdf');

// Browser β€” pass a File object from <input type="file">
await m.addFile(fileInput.files[0]);
Copy & paste β€” that's it
# REST API
curl -X POST https://mengram.io/v1/add_file \
  -H "Authorization: Bearer om-..." \
  -F "file=@meeting-notes.pdf" \
  -F "user_id=default"
</details> <details> <summary><b>JavaScript / TypeScript</b></summary>
Copy & paste β€” that's it
npm install mengram-ai
Copy & paste β€” that's it
const { MengramClient } = require('mengram-ai');
const m = new MengramClient('om-...');

await m.add([{ role: 'user', content: 'Fixed OOM by adding Redis cache layer' }]);
const results = await m.searchAll('database issues');
// β†’ { semantic: [...], episodic: [...], procedural: [...] }
</details> <details> <summary><b>REST API (curl)</b></summary>
Copy & paste β€” that's it
# Add memory
curl -X POST https://mengram.io/v1/add \
  -H "Authorization: Bearer om-..." \
  -H "Content-Type: application/json" \
  -d '{"messages": [{"role": "user", "content": "I prefer dark mode and vim keybindings"}]}'

# Search all 3 types
curl -X POST https://mengram.io/v1/search/all \
  -H "Authorization: Bearer om-..." \
  -d '{"query": "user preferences"}'
</details>

3 Memory Types

Semantic β€” facts, preferences, knowledge

Copy & paste β€” that's it
m.search("tech stack")
# β†’ ["Uses Python 3.12", "Deploys to Railway", "PostgreSQL with pgvector"]

Episodic β€” events, decisions, outcomes

Copy & paste β€” that's it
m.episodes(query="deployment")
# β†’ [{summary: "DB crashed due to missing migrations", outcome: "resolved", date: "2025-05-12"}]

Procedural β€” workflows that evolve

Copy & paste β€” that's it
Week 1:  "Deploy" β†’ build β†’ push β†’ deploy
                                         ↓ FAILURE: forgot migrations
Week 2:  "Deploy" v2 β†’ build β†’ run migrations β†’ push β†’ deploy
                                                          ↓ FAILURE: OOM
Week 3:  "Deploy" v3 β†’ build β†’ run migrations β†’ check memory β†’ push β†’ deploy βœ…

This happens automatically when you report failures:

Copy & paste β€” that's it
m.procedure_feedback(proc_id, success=False,
                     context="OOM error on step 3", failed_at_step=3)
# β†’ Procedure evolves to v3 with new step added

Or fully automatic β€” just add conversations and Mengram detects failures and evolves procedures:

Copy & paste β€” that's it
m.add([{"role": "user", "content": "Deploy failed again β€” OOM on the build step"}])
# β†’ Episode created β†’ linked to "Deploy" procedure β†’ failure detected β†’ v3 created

Ask Your Memory (RAG built-in)

m.ask() returns a synthesized answer with citations β€” not a raw fact list. Mengram embeds your query, retrieves the top relevant facts, and uses Cohere Chat to write a grounded answer with native source attribution.

Copy & paste β€” that's it
result = m.ask("what programming languages do I use?")

print(result["answer"])
# 'You use Python and Rust. Python is your daily language [1] and
#  Rust is your favorite [2]. You also know Java for enterprise
#  systems [3].'

for cit in result["citations"]:
    print(f'  "{cit["text"]}" β†’ {cit["sources"][0]["fact"]}')
# "Python and Rust" β†’ uses Python daily for backend development
# "favorite [2]"   β†’ Rust is favorite language
# "Java"           β†’ specializes in Java/Spring Boot

Multilingual: ask in any of 23 languages, get an answer in the same language with citations linking back to facts in the original language they were stored. Premium feature (Pro / Growth / Business).

Cognitive Profile

One API call generates a system prompt from all memories:

Copy & paste β€” that's it
profile = m.get_profile()
# β†’ "You are talking to Ali, a developer in Almaty. Uses Python, PostgreSQL,
#    and Railway. Recently debugged pgvector deployment. Prefers direct
#    communication and practical next steps."

Insert into any LLM's system prompt for instant personalization.

Import Existing Data

Kill the cold-start problem:

Copy & paste β€” that's it
mengram import chatgpt ~/Downloads/chatgpt-export.zip --cloud   # ChatGPT history
mengram import obsidian ~/Documents/MyVault --cloud              # Obsidian vault
mengram import files notes/*.md --cloud                          # Any text/markdown

Integrations

<table> <tr> <td width="50%">

Claude Code β€” Auto-memory hooks

Copy & paste β€” that's it
mengram hook install

3 hooks: profile on start, recall on every prompt, save after responses. Zero manual effort.

Docs

</td> <td width="50%">

MCP Server β€” Claude Desktop, Cursor, Codex, Windsurf, Cline

Copy & paste β€” that's it
{
  "mcpServers": {
    "mengram": {
      "command": "mengram",
      "args": ["server", "--cloud"],
      "env": { "MENGRAM_API_KEY": "om-..." }
    }
  }
}

30 tools for memory management.

</td> </tr> <tr> <td width="50%">

LangChain β€” pip install langchain-mengram

Copy & paste β€” that's it
from langchain_mengram import (
    MengramRetriever,
    MengramChatMessageHistory,
)

retriever = MengramRetriever(api_key="om-...")
docs = retriever.invoke("deployment issues")
</td> <td width="50%">

CrewAI

Copy & paste β€” that's it
from integrations.crewai import create_mengram_tools

tools = create_mengram_tools(api_key="om-...")
# β†’ 5 tools: search, remember, profile,
#   save_workflow, workflow_feedback

agent = Agent(role="Support", tools=tools)
</td> </tr> <tr> <td width="50%">

OpenClaw

Copy & paste β€” that's it
openclaw plugins install openclaw-mengram

Auto-recall before every turn, auto-capture after. 12 tools, slash commands, Graph RAG.

GitHub Β· npm

</td> <td width="50%">

CLI β€” Full command-line interface

Copy & paste β€” that's it
mengram search "deployment" --cloud
mengram profile --cloud
mengram import chatgpt export.zip --cloud
mengram hook install

Docs

</td> </tr> <tr> <td width="50%">

Claude Managed Agents β€” MCP memory for hosted agents

Copy & paste β€” that's it
{
  "mcp_servers": [{
    "type": "url",
    "name": "mengram",
    "url": "https://mengram.io/mcp/sse"
  }]
}

30 memory tools via MCP. Docs

</td> <td width="50%">

n8n β€” HTTP nodes for any workflow

Copy & paste β€” that's it
POST https://mengram.io/v1/add
POST https://mengram.io/v1/search

No code needed β€” drag and drop memory into any n8n workflow.

Docs

</td> </tr> </table>

Multi-User Isolation

One API key, many users β€” each sees only their own data:

Copy & paste β€” that's it
m.add([...], user_id="alice")
m.add([...], user_id="bob")

m.search_all("preferences", user_id="alice")  # Only Alice's memories
m.get_profile(user_id="alice")                 # Alice's cognitive profile

Async Client

Non-blocking Python client built on httpx:

Copy & paste β€” that's it
from mengram import AsyncMengram

async with AsyncMengram() as m:
    await m.add([{"role": "user", "content": "I use async/await"}])
    results = await m.search("async")
    profile = await m.get_profile()

Install with pip install mengram-ai[async].

Metadata Filters

Filter search results by metadata:

Copy & paste β€” that's it
results = m.search("config", filters={"agent_id": "support-bot", "app_id": "prod"})

Webhooks

Get notified when memories change:

Copy & paste β€” that's it
m.create_webhook(
    url="https://your-app.com/hook",
    event_types=["memory_add", "memory_update"],
)

Agent Templates

Clone, set API key, run in 5 minutes:

TemplateStackWhat it shows
DevOps AgentPython SDKProcedures that evolve from deployment failures
Customer SupportCrewAIAgent with 5 memory tools, remembers returning customers
Personal AssistantLangChainCognitive profile + auto-saving chat history
Copy & paste β€” that's it
cd examples/devops-agent && pip install -r requirements.txt
export MENGRAM_API_KEY=om-...
python main.py

Use with AI Agents

Mengram works as a persistent memory backend for autonomous agents. Your agent stores what it learns, and recalls it on the next run β€” getting smarter over time.

Copy & paste β€” that's it
from mengram import Mengram

m = Mengram(api_key="om-...")

# Agent completes a task β†’ store what happened
m.add([
    {"role": "user", "content": "Apply to Acme Corp on Greenhouse"},
    {"role": "assistant", "content": "Applied successfully. Had to use React Select workaround for dropdowns."},
])
# β†’ Extracts: fact ("applied to Acme Corp"), episode ("Greenhouse application"),
#   procedure ("React Select dropdown workaround")

# Next run β†’ agent recalls what worked before
context = m.search_all("Greenhouse application tips")
# β†’ Returns past procedures, failures, and successful strategies

# Report outcome β†’ procedures evolve
m.procedure_feedback(proc_id, success=False,
                     context="Dropdown fix stopped working")
# β†’ Procedure auto-evolves to a new version

Works with any agent framework β€” CrewAI, LangChain, AutoGPT, custom loops. The agent just calls add() after actions and search() before decisions.

Self-Hosted (Ollama)

When running locally with Ollama, use models with 8B+ parameters and 8K+ context window. The extraction prompt is ~4,000 tokens β€” smaller models will hallucinate or mix examples with real data.

ModelParametersWorks?
llama3.1:8b8BYes
mistral:7b7BYes
gemma2:9b9BYes
llama3.1:70b70BBest
phi4-mini:3.8b3.8BNo β€” context too small

API Reference

EndpointDescription
POST /v1/addAdd memories (auto-extracts all 3 types)
POST /v1/add_textAdd memories from plain text
POST /v1/add_fileUpload file (PDF, DOCX, TXT, MD) β€” vision AI extraction
POST /v1/searchSemantic search
POST /v1/search/allUnified search (semantic + episodic + procedural)
GET /v1/episodes/searchSearch events and decisions
GET /v1/procedures/searchSearch workflows
PATCH /v1/procedures/{id}/feedbackReport outcome β€” triggers evolution
GET /v1/procedures/{id}/historyVersion history + evolution log
GET /v1/profileCognitive Profile
GET /v1/triggersSmart Triggers (reminders, contradictions, patterns)
POST /v1/agents/runMemory agents (Curator, Connector, Digest)
GET /v1/meAccount info

Full interactive docs: mengram.io/docs

Quota Headers

Every authenticated response includes usage headers:

HeaderDescription
X-Quota-Add-UsedAdd calls used this month
X-Quota-Add-LimitAdd calls allowed this month
X-Quota-Search-UsedSearch calls used this month
X-Quota-Search-LimitSearch calls allowed this month

SDKs expose this via .quota:

Copy & paste β€” that's it
m.search("test")
print(m.quota)  # {"add": {"used": 5, "limit": 30}, "search": {"used": 12, "limit": 100}}

Community

Star History

<a href="https://star-history.com/#alibaizhanov/mengram&Date"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=alibaizhanov/mengram&type=Date&theme=dark" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=alibaizhanov/mengram&type=Date" /> <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=alibaizhanov/mengram&type=Date" /> </picture> </a>

License

Apache 2.0 β€” free for commercial use.


<div align="center">

Get your free API key Β· Built by Ali Baizhanov Β· mengram.io

</div>