Memory Graph MCP server

Provides long-term memory storage for LLM conversations using Redis Graph, enabling persistent knowledge graphs for maintaining context across interactions and building complex information networks.
Back to servers
Setup instructions
Provider
Sam Wang
Release date
Mar 01, 2025
Language
TypeScript
Stats
3 stars

This MCP Memory server provides a conversation memory system for LLMs using Redis Graph for knowledge storage. It allows creating relationships between different types of memory nodes and provides powerful search capabilities.

Prerequisites

  • Docker and Docker Compose
  • Node.js (v16 or higher)

Installation

Setting up Redis with RedisGraph

  1. Start the Redis container with RedisGraph module:
docker-compose up -d
  1. Verify that Redis is running with the RedisGraph module:
docker exec -it mcp-memory-redis-1 redis-cli
  1. Once in the Redis CLI, check if the RedisGraph module is loaded:
127.0.0.1:6379> MODULE LIST

You should see RedisGraph in the list of loaded modules.

Setting up the Application

  1. Install dependencies:
npm install
  1. Start the application:
npm start

By default, the application connects to Redis at localhost:6379. If you need to change these settings, update the Redis client configuration in src/index.ts.

Usage

Memory Tools

The application provides several tools for managing memories:

  • create_memory: Create a new memory
  • retrieve_memory: Retrieve a memory by ID
  • search_memories: Search for memories by type or keyword
  • update_memory: Update an existing memory
  • delete_memory: Delete a memory
  • create_relation: Create a relationship between memories
  • get_related_memories: Get memories related to a specific memory

Memory Types

The system supports various memory types:

  • Conversation: General conversation memories
  • Topic: Specific topics discussed
  • Project: Project details
  • Task: Specific tasks
  • Issue: Bugs or incidents
  • Config: Configuration details
  • Finance: Financial advice or information
  • Todo: Todo items

Example: Creating a Memory

const memory = await memoryService.createMemory({
  type: MemoryNodeType.CONVERSATION,
  content: 'This is a conversation about Redis Graph',
  title: 'Redis Graph Discussion',
});

Example: Searching Memories

const memories = await memoryService.searchMemories(
  { keyword: 'Redis' },
  { limit: 10, orderBy: 'created', direction: 'DESC' },
);

Example: Project Details

create_memory(
  type: "Project",
  name: "Fiat Vendor Disable Script",
  description: "Script to disable fiat vendors in the system",
  content: "The script is located at /scripts/disable-vendor.js and takes vendor ID as parameter"
)

Example: Issue Handling

create_memory(
  type: "Issue",
  title: "Payment Processing Timeout",
  severity: "high",
  status: "open",
  content: "Payments are timing out when processing large transactions over $10,000"
)

Example: Creating Relationships

create_relation(
  fromId: "issue-123",
  toId: "project-456",
  type: "PART_OF"
)

Working with Redis Graph

Using the Redis CLI Helper

npm run redis:cli

This will open a Redis CLI session with useful commands for working with the memory graph.

Checking the Graph

npm run check:graph

This shows all nodes, Finance memories, and relationships in the graph.

Inspecting the Graph

npm run inspect:graph

Useful RedisGraph Commands

  1. List all graphs:

    GRAPH.LIST
    
  2. Count all nodes:

    GRAPH.QUERY memory "MATCH (n) RETURN count(n)"
    
  3. View Finance memories:

    GRAPH.QUERY memory "MATCH (n:Finance) RETURN n.id, n.title, n.content"
    
  4. Search for specific content:

    GRAPH.QUERY memory "MATCH (n) WHERE n.content CONTAINS 'debit card' RETURN n.id, n.type, n.content"
    

Running in Docker

To run the MCP Memory server in Docker:

# Build the Docker image
docker build -t mcp/memory .

# Run the container on the same network as Redis
docker run --rm -i --network=mcp-memory_default -e REDIS_URL=redis://redis:6379 mcp/memory

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mcp-memory" '{"command":"npx","args":["-y","mcp-memory"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mcp-memory": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-memory"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mcp-memory": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-memory"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later