← Back to directory
M

Mengram MCP Server

Official
Long-term memory for AI agents that actually learns
GitHub source repository ↗
★ 196 Stars Category · Dev Tools Very popular
57FMRS · C

Mengram is a memory MCP server for AI agents whose distinguishing feature is covering semantic, episodic, and procedural memory at once, with procedures that evolve on failure and carry derived preconditions. It ships a free API key, Python and JS SDKs, LangChain, CrewAI, and OpenClaw integrations, and connects to Claude Desktop, Cursor, Codex, Windsurf, and Cline via a hosted streamable-http endpoint or a local stdio server. It fits coding agents and autonomous-agent developers that need persistent cross-session memory, but not single-turn or strictly component-free local setups. The main trade-offs are that cloud mode uploads content to a third party and that automatic hooks and self-evolving procedures shape both context and pre-command prompts.

Reliability
9/20
Security and permissions
11/20
Maintenance
12/20
Documentation
13/20
Setup experience
12/20
Read the FMRS scoring method →

Mengram is a long-term memory service for AI agents, storing three memory types: semantic (facts and preferences), episodic (events and decisions), and procedural (workflows). Procedures evolve into new versions when failures are reported, recording the assumption that turned out false and deriving preconditions carried at recall time. Mengram offers a free API key, Python and JavaScript SDKs, and LangChain, CrewAI, and OpenClaw integrations, and exposes an MCP server to Claude Desktop, Cursor, Codex, Windsurf, and Cline (the README mentions 30 tools). The server is hosted at https://mengram.io/mcp over streamable-http and requires an Authorization: Bearer <API key> header. It includes native multilingual retrieval across 23 languages, an ask endpoint returning synthesized answers with citations, and a Cognitive Profile that generates a system prompt from all memories. The project is Apache-2.0 licensed and can be self-hosted with Ollama.

Setup

  1. Get a free API key at https://mengram.io/#signup (format om-...).
  2. Install the SDK: pip install mengram-ai or npm install mengram-ai.
  3. Option A (hosted remote): point your client at https://mengram.io/mcp and authenticate with the Authorization: Bearer <your key> header.
  4. Option B (local stdio): add an mcpServers entry with command mengram, args ["server", "--cloud"], and env MENGRAM_API_KEY.
  5. Alternatively run mengram setup, which handles the account, Claude Code hooks, MCP configs for detected tools (Cursor, Claude Desktop, Windsurf), and history import.
  6. Verify the round-trip with a search or ask call.
claude_desktop_config.json
{
  "mcpServers": {
    "mengram": {
      "command": "mengram",
      "args": ["server", "--cloud"],
      "env": { "MENGRAM_API_KEY": "om-..." }
    }
  }
}

Fit and risk

Best for

  • Coding agents and CLI workflows that need persistent memory across sessions and machines (Claude Code, Codex, Cursor)
  • Developers building autonomous agents that need semantic, episodic, and evolving procedural memory
  • Teams using LangChain, CrewAI, or OpenClaw who want a ready memory backend
  • Apps that need multi-user data isolation under a single API key
  • Teams wanting an account-free, folder-based memory that uses their own model provider (Anthropic, OpenAI, or Ollama)

Not for

  • Single-turn chats or scenarios with no need for cross-session state
  • Environments requiring a fully local setup with no SDK or CLI installed (local mode still needs pip install mengram-ai and your own model key)
  • High-concurrency writes demanding whole-folder crash-atomic transactions (the folder is not a single crash-atomic transaction and external editors do not participate in the lock)
  • Self-hosters expecting good extraction from models under 8B parameters or with less than an 8K context window

Required permissions

  • A Mengram API key sent as an Authorization: Bearer header for cloud memory reads and writes
  • In cloud mode, conversations are sent to mengram.io for extraction, embedding, and retrieval
  • Claude Code hooks can read session history and working state and re-inject context before and after compaction
  • `mengram import claude-code` reads local Claude Code session history (the README states secrets are redacted on your machine before upload)
  • The policy gate looks up learned workflows before workflow-shaped Bash commands and can be pointed at a local memory folder via MENGRAM_MEMORY_DIR

Risks and side effects

  • Cloud mode uploads conversations and file content to a third-party service, which may include sensitive data; local mode avoids this but needs your own model key
  • Auto-save and auto-recall hooks read and write memory in the background, which can introduce unwanted context
  • Incorrect memories get re-recalled and injected into system prompts, with a persistent effect
  • Procedures evolve automatically and the policy gate can prompt before command execution, so misconfiguration may cause false alarms
  • In folder mode concurrent external edits are not lock-protected and can be overwritten; local search matches words and does not use embeddings or translation

Troubleshooting

  1. Confirm the Authorization header uses Bearer <om-...> with a valid key; call GET /v1/me to verify the account
  2. If cloud calls are rejected, check quota headers X-Quota-Add-Used/Limit and X-Quota-Search-Used/Limit, or inspect .quota from the SDK
  3. Distinguish transports on connection failure: the hosted endpoint is streamable-http at https://mengram.io/mcp; local stdio requires the `mengram` command on PATH
  4. If self-hosted Ollama results are poor, switch to a model with 8B+ parameters and 8K+ context (e.g. llama3.1:8b, mistral:7b, gemma2:9b)
  5. If a file upload returns no result, poll job status with m.job_status(job_id)
  6. Tune policy-gate behavior with MENGRAM_POLICY_MIN_RELIABLE and MENGRAM_POLICY_PATTERN, or disable it with `mengram hook install --no-policy`
  7. In folder mode, conflicting edits require a reload rather than overwriting; check the folder lock state

Use cases

Keep coding-agent context alive across /clear, auto-compaction, machine switches, and team handoffs
Store what an autonomous agent learns each run and recall it before the next decision
Record deployment failures so a Deploy procedure evolves with new steps and preconditions
Generate a personalization system prompt from all memories via the Cognitive Profile call
Import existing data (Claude Code sessions, ChatGPT exports, Obsidian vaults, text files) to skip the cold start
Run multilingual memory retrieval and cited answers across 23 languages

Supported clients

Claude DesktopFull support
CursorPartial support
CodexPartial support
WindsurfFull support
ClineFull support
Claude CodeFull support
OpenClawFull support
LangChainFull support
CrewAIFull support