Memory MCP — Persistent AI Agent Knowledge Graph
MCP server that gives AI agents persistent memory using a local knowledge graph. Stores entities, relationships, and observations across sessions for Claude Code.
Staging sûr pour cet actif
Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.
npx -y tokrepo@latest install 554c4dc2-663c-489a-b57f-814948e9f714 --target codexStage les fichiers d'abord; l'activation exige la revue du README et du plan staged.
What it is
Memory MCP is a Model Context Protocol server that provides AI agents with persistent memory via a local knowledge graph. The agent can create entities (people, projects, concepts), add observations about them, and define relationships between them. This structured memory persists across sessions.
It is part of the official MCP server collection and targets developers who want their AI agents to build and maintain a knowledge base over time rather than starting fresh each conversation.
How it saves time or tokens
Without persistent memory, every AI conversation starts from zero. You re-explain your project structure, preferences, and context. Memory MCP lets the agent store and retrieve this information, reducing repeated context-setting.
The estimated token cost for this workflow is approximately 4,000 tokens. The knowledge graph format is more structured than raw text memory, making retrieval more precise.
How to use
- Add to your MCP configuration:
{
"mcpServers": {
"memory": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-memory"]
}
}
}
- Restart Claude Code or your MCP-compatible agent.
- The agent now has tools to create entities, add observations, and query the knowledge graph:
You: Remember that our project uses PostgreSQL 16 with pgvector
Agent: I will store this in my knowledge graph...
[Creates entity: 'Project Database' with observation: 'Uses PostgreSQL 16 with pgvector']
Example
// Example knowledge graph operations the agent performs:
// Create an entity
{"tool": "create_entities", "entities": [
{"name": "TokRepo", "entityType": "project",
"observations": ["Nuxt 3 + Go-Zero stack", "Port 3001 frontend"]}
]}
// Create a relationship
{"tool": "create_relations", "relations": [
{"from": "TokRepo", "to": "PostgreSQL", "relationType": "uses"}
]}
// Search memory
{"tool": "search_nodes", "query": "database"}
// Returns: TokRepo -> uses -> PostgreSQL
Related on TokRepo
- AI Memory Tools -- Compare memory solutions for AI agents
- MCP Integrations -- Database and storage MCP servers
Common pitfalls
- The knowledge graph is stored as a local JSON file. If you delete the file, all memory is lost. Back it up if the data matters.
- Memory MCP stores everything the agent decides to remember. Over time the graph can grow large. Periodically review and prune irrelevant entities.
- The agent must be explicitly asked to remember or check memory. It does not automatically store or retrieve information unless prompted.
Questions fréquentes
By default, Memory MCP stores the knowledge graph as a JSON file in the local filesystem. The exact location depends on your MCP configuration. You can specify a custom path via environment variables.
Yes. If two MCP clients point to the same memory file, they share the knowledge graph. However, there is no built-in conflict resolution for concurrent writes.
Memory MCP stores structured entities and relationships in a knowledge graph. Vector databases store embeddings for semantic search. Memory MCP is better for facts and relationships; vector databases are better for fuzzy similarity search.
The agent uses the memory tools when it determines information should be stored or retrieved. You can prompt it to remember specific facts, or configure system prompts that instruct the agent to actively use its memory.
Yes. The knowledge graph is stored as a JSON file that you can open and edit with any text editor. The format uses entities, observations, and relations arrays.
Sources citées (3)
- MCP Servers GitHub— Memory MCP provides persistent knowledge graph for AI agents
- MCP Specification— Part of the official Model Context Protocol server collection
- Memory MCP README— Stores entities, relationships, and observations in structured format
En lien sur TokRepo
Source et remerciements
Created by Anthropic. Licensed under MIT.
modelcontextprotocol/servers — Part of the official MCP servers collection
Fil de discussion
Actifs similaires
Codebase Memory MCP — Code Knowledge Graph Server
High-performance MCP server that indexes codebases into persistent knowledge graphs. Supports 66 languages, sub-millisecond queries, and claims 99% fewer tokens than raw file context. 1,100+ stars.
Engram — Persistent Memory System for AI Agents
Agent-agnostic persistent memory system with SQLite full-text search. Ships as MCP server, HTTP API, CLI, and TUI. Gives any AI coding agent long-term memory across sessions. 2,300+ stars.
omega-memory — Persistent Memory for Coding Agents
OMEGA is a local-first, cross-model memory system for coding agents. It runs an MCP server plus hooks so recall is automatic across sessions.
DuckDB Graph Memory MCP — File-Backed Memory DB
DuckDB Graph Memory MCP is a fork of the MCP memory server that stores the knowledge graph in a DuckDB file for SQL queries and scaling beyond JSON.