AI Frameworks·
intermediate
·10 min read·Apr 4, 2026

How to Use the Memory MCP Server for Persistent AI Knowledge

Give your AI agent persistent memory using the Knowledge Graph MCP server. Store and retrieve information across conversations.

memoryknowledge graphpersistent statecontextlong-term memoryarchitecture

Use the Memory MCP Server for Persistent AI Knowledge

The Memory MCP server (also known as the Knowledge Graph server) provides AI agents with the ability to store and retrieve information across completely separate conversations. This bridges the gap between ephemeral chat sessions and a truly personalized, long-term AI assistant.

Why Persistent Memory?

By default, AI agents have amnesia—they forget everything the moment you clear the chat window. The Memory server solves this by:

  • Storing facts, user preferences, and context as a structured knowledge graph.
  • Allowing autonomous retrieval of past information in new conversations.
  • Building a personal knowledge base that grows smarter over time.

Prerequisites

  • Node.js 18+ installed on your host machine.
  • An MCP-compatible client like Claude Desktop.

Configuration Setup

json
{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"],
      "env": {
        "MEMORY_FILE_PATH": "/absolute/path/to/your/memory.json"
      }
    }
  }
}

(We strongly recommend setting an absolute MEMORY_FILE_PATH, otherwise the graph will be saved to a temporary directory that might be wiped on reboot).

How It Works

The memory server stores information as a Knowledge Graph. Instead of plain text, the AI maps concepts using:

  • Entities: People, projects, concepts (Nodes)
  • Relations: Connections between entities (Edges)
  • Observations: Specific facts about entities (Properties)

Available Tools

Your agent will automatically use these tools to manage the graph:

ToolDescription
create_entitiesAdd new entities to the graph
create_relationsConnect entities with relationships
add_observationsAdd facts about entities
delete_entitiesRemove entities
delete_observationsRemove specific facts
read_graphRead the entire knowledge graph
search_nodesSearch for specific entities

Example Workflows

  • Storing Context: "Remember that Project Alpha is using React and TypeScript, is led by Sarah, and has a deadline of March 15th."
  • Retrieving Information: "What do you know about Project Alpha? Search your memory graph."
  • Building Relationships: "Sarah manages Project Alpha and reports to David. David oversees the Engineering department. Map this out in memory."

Best Practices & Troubleshooting

  • Explicit Prompts: Tell the AI to "remember this" explicitly. Otherwise, the AI might just acknowledge your message without actually invoking the add_observations tool.
  • Node Duplication: Sometimes the AI will create duplicate entities (e.g., ProjectAlpha and Project_Alpha). Periodically instruct the AI to review the graph, identify duplicates, and merge them using the delete_entities tool.
  • File Permissions: If the agent throws an error when trying to write to memory, ensure the user running the MCP client has write permissions for the directory specified in MEMORY_FILE_PATH.

Using with OpenAI Codex

You can use this MCP server with the OpenAI Codex CLI by adding it to your configuration:

bash
codex mcp add --name memory --command "npx -y @modelcontextprotocol/server-memory"

For a full list of recommended servers, see Best MCP Servers for OpenAI Codex.