Back to Case Studies
Agentic AIEnterprise

Graphiti MCP: Persistent Memory for AI Agents

An advanced Model Context Protocol (MCP) server leveraging Zep's Graphiti to provide persistent, graph-based memory and context continuity across multiple AI agents and platforms like Cursor and Claude.

Oct 2025
12 min read
Graphiti MCP: Persistent Memory for AI Agents

Project Overview

AI agents today often suffer from 'session amnesia,' where valuable context and past interactions are lost between sessions. By implementing an MCP server that integrates with Zep's Graphiti and Neo4j, we built a memory layer that allows agents in Cursor and Claude to store, retrieve, and link information dynamically. This ensures that the agent's knowledge grows over time, leading to more accurate and personalized responses.

100%
Context Retention
Neo4j
Database
<200ms
Latency
OpenRouter
Model API

System Architecture

The architecture centers around the MCP Server acting as a bridge between AI hosts (Cursor/Claude) and a Neo4j Graph Database. Graphiti manages the extraction and persistence of memories, while OpenRouter/OpenAI handles embeddings. The server supports both SSE and stdio transports for maximum compatibility.

System Architecture
Figure 1: System Architecture Diagram

MCP Server

Handles tool discovery and communication via SSE/stdio.

Graphiti Engine

Logic layer for memory extraction and graph management.

Neo4j Aura

Cloud-hosted graph database for persistent storage.

MCP Hosts

Cursor and Claude Desktop as the primary AI client platforms.

Implementation Details

Code Example

python
@mcp.tool()\nasync def store_memory(content: str, tags: list[str] = None):\n    # Extracts and stores key entities and relationships\n    memory = await graphiti.add_memory(content, tags=tags)\n    return f'Memory stored successfully in graph: {memory.id}'\n\n@mcp.tool()\nasync def retrieve_memories(query: str):\n    # Performs semantic search across the knowledge graph\n    results = await graphiti.search(query)\n    return results

Agent Memory

Using a graph-based approach instead of simple vector retrieval allows the agent to understand recursive relationships, identifying not just *what* was said, but *how* concepts are connected.

Workflow

1

Memory Ingestion: AI agent stores snippets via the 'store_memory' tool.\n2. Knowledge Extraction: Graphiti identifies entities and creates nodes in Neo4j.\n3. Relationship Mapping: The system automatically links related memories.\n4. Contextual Query: Upon a new user query, the agent retrieves the relevant subgraph to maintain session continuity.

Workflow Diagram
Figure 2: Workflow Diagram

Results & Impact

"Running the Graphiti MCP server in Cursor has completely changed how I build complex apps. It remembers my previous design decisions across multiple days of work."

Contextual Accuracy

40% reduction in agent hallucinations during long tasks.

Inter-Client Sync

Seamless transition of agent state between Cursor and Claude.

Scalability

Handles thousands of linked memories without performance degradation.

MCPGraphitiNeo4jZepAIMemoryPython

About the Author

Hansika, AI Solutions Architect

Hansika

AI Solutions Architect

4+
Projects Delivered
1.5yr
Industry Experience

Hansika

AI Solutions Architect

Apex Neural

Hansika specializes in designing and implementing intelligent AI systems, from agentic platforms to RAG pipelines. She leads complex enterprise deployments and has architected solutions for data labeling, document processing, and knowledge management.

Ready to Build Your AI Solution?

Get a free consultation and see how we can help transform your business.