Mengram
Human-like memory layer for AI agents with semantic, episodic, and procedural memory types, cognitive profiling, knowledge graph, and 12 MCP tools.
pip install mengram-ai # or: npm install mengram-ai
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.episodes(query="deployment") # → events
m.procedures(query="deploy") # → workflows that evolve from failures
Claude Code — Zero-Config Memory
Two commands. Claude Code remembers everything across sessions automatically.
pip install mengram-ai
mengram setup # Sign up + install hooks (interactive)
Or manually: export MENGRAM_API_KEY=om-... → mengram hook install
What happens:
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.
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.
| Mengram | Mem0 | Zep | Letta | |
|---|---|---|---|---|
| Semantic memory (facts, preferences) | Yes | Yes | Yes | Yes |
| Episodic memory (events, decisions) | Yes | No | No | Partial |
| Procedural memory (workflows) | Yes | No | No | No |
| Procedures evolve from failures | Yes | No | No | No |
| Cognitive Profile | Yes | No | No | No |
| Multi-user isolation | Yes | Yes | Yes | No |
| Knowledge graph | Yes | Yes | Yes | Yes |
| Claude Code hooks (auto-save/recall) | Yes | No | No | No |
| LangChain + CrewAI + MCP | Yes | Partial | Partial | Partial |
| Import ChatGPT / Obsidian | Yes | No | No | No |
| Pricing | Free tier | $19-249/mo | Enterprise | Self-host |
Get Started in 30 Seconds
1. Install
pip install mengram-ai
2. Setup (creates account + installs Claude Code hooks)
mengram setup
Or get a key manually at mengram.io and export MENGRAM_API_KEY=om-...
3. Use
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: [...]}
File Upload (PDF, DOCX, TXT, MD)
# 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"])
// 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]);
# REST API
curl -X POST https://mengram.io/v1/add_file \
-H "Authorization: Bearer om-..." \
-F "[email protected]" \
-F "user_id=default"
JavaScript / TypeScript
npm install mengram-ai
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: [...] }
REST API (curl)
# 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"}'
3 Memory Types
Semantic — facts, preferences, knowledge
m.search("tech stack")
# → ["Uses Python 3.12", "Deploys to Railway", "PostgreSQL with pgvector"]
Episodic — events, decisions, outcomes
m.episodes(query="deployment")
# → [{summary: "DB crashed due to missing migrations", outcome: "resolved", date: "2025-05-12"}]
Procedural — workflows that evolve
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:
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:
m.add([{"role": "user", "content": "Deploy failed again — OOM on the build step"}])
# → Episode created → linked to "Deploy" procedure → failure detected → v3 created
Cognitive Profile
One API call generates a system prompt from all memories:
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:
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
|
Claude Code — Auto-memory hooks
3 hooks: profile on start, recall on every prompt, save after responses. Zero manual effort. |
MCP Server — Claude Desktop, Cursor, Windsurf
29 tools for memory management. |
|
LangChain —
|
CrewAI
|
|
OpenClaw
Auto-recall before every turn, auto-capture after. 12 tools, slash commands, Graph RAG. |
CLI — Full command-line interface
|
Multi-User Isolation
One API key, many users — each sees only their own data:
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:
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:
results = m.search("config", filters={"agent_id": "support-bot", "app_id": "prod"})
Webhooks
Get notified when memories change:
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:
| Template | Stack | What it shows |
|---|---|---|
| DevOps Agent | Python SDK | Procedures that evolve from deployment failures |
| Customer Support | CrewAI | Agent with 5 memory tools, remembers returning customers |
| Personal Assistant | LangChain | Cognitive profile + auto-saving chat history |
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.
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.
API Reference
| Endpoint | Description |
|---|---|
POST /v1/add | Add memories (auto-extracts all 3 types) |
POST /v1/add_text | Add memories from plain text |
POST /v1/add_file | Upload file (PDF, DOCX, TXT, MD) — vision AI extraction |
POST /v1/search | Semantic search |
POST /v1/search/all | Unified search (semantic + episodic + procedural) |
GET /v1/episodes/search | Search events and decisions |
GET /v1/procedures/search | Search workflows |
PATCH /v1/procedures/{id}/feedback | Report outcome — triggers evolution |
GET /v1/procedures/{id}/history | Version history + evolution log |
GET /v1/profile | Cognitive Profile |
GET /v1/triggers | Smart Triggers (reminders, contradictions, patterns) |
POST /v1/agents/run | Memory agents (Curator, Connector, Digest) |
GET /v1/me | Account info |
Full interactive docs: mengram.io/docs
Community
- GitHub Issues — bug reports, feature requests
- API Docs — interactive Swagger UI
- Examples — ready-to-run agent templates
License
Apache 2.0 — free for commercial use.
Get your free API key · Built by Ali Baizhanov · mengram.io
Máy chủ liên quan
ServiceNow MCP Server
An MCP server for interfacing with ServiceNow, enabling AI agents to access and manipulate data via a secure API.
Google Security
Access Google's security products and services, including Chronicle, SOAR, Threat Intelligence (GTI), and Security Command Center (SCC).
AWS MCP Servers
A suite of MCP servers providing AI applications with access to AWS documentation, contextual guidance, and best practices.
Alpaca MCP Gold Standard
A server for interacting with the Alpaca trading API. Requires API credentials via environment variables.
MCP Salesforce Connector
Interact with Salesforce data using SOQL queries and SOSL searches via an MCP server.
Red Bee MCP Server
An MCP server for the Red Bee Media OTT Platform, offering tools for authentication, content search, user management, purchases, and system operations.
MCP Bybit API Interface
An interface for interacting with the Bybit cryptocurrency exchange API.
AWS Cost Analysis
Analyze CDK projects to identify AWS services used and get pricing information from AWS pricing webpages and API.
Authless Remote MCP Server
An authentication-free, remote MCP server designed for deployment on Cloudflare Workers.
AlibabaCloud DevOps MCP
Yunxiao MCP Server provides AI assistants with the ability to interact with the Yunxiao platform.