RAG Memory MCP server

Provides a knowledge graph-enhanced retrieval system that combines vector search with graph-based relationships for persistent memory and contextual information retrieval
Back to servers
Provider
ttommyth
Release date
May 25, 2025
Language
TypeScript
Stats
5 stars

RAG-enabled MCP server offers advanced memory management through a knowledge graph with vector search capabilities. It extends basic memory concepts with semantic search, document processing, and hybrid retrieval for more intelligent information management. The server runs locally alongside MCP clients and uses local file system access for database storage.

Installation and Setup

Client Configuration

Claude Desktop / Cursor Configuration

Add the following to your claude_desktop_config.json (Claude Desktop) or mcp.json (Cursor):

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

To specify a version:

{
  "mcpServers": {
    "rag-memory": {
      "command": "npx",
      "args": ["-y", "[email protected]"]
    }
  }
}

To customize the database location:

{
  "mcpServers": {
    "rag-memory": {
      "command": "npx",
      "args": ["-y", "rag-memory-mcp"],
      "env": {
        "MEMORY_DB_PATH": "/path/to/custom/memory.db"
      }
    }
  }
}

VS Code Configuration

Add this to your User Settings (JSON) file or .vscode/mcp.json:

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

Key Features and Tools

Document Management

  • storeDocument: Save documents with metadata
  • chunkDocument: Break text into manageable chunks
  • embedChunks: Generate vector embeddings for search
  • extractTerms: Automatically identify entities
  • linkEntitiesToDocument: Connect entities to documents
  • deleteDocuments: Remove documents and related data
  • listDocuments: View all stored documents

Knowledge Graph Operations

  • createEntities: Add new entities with observations
  • createRelations: Define relationships between entities
  • addObservations: Expand entity information
  • deleteEntities: Remove entities and connections
  • deleteRelations: Remove specific relationships
  • deleteObservations: Remove specific entity facts

Search and Retrieval

  • hybridSearch: Combine vector similarity with graph traversal
  • searchNodes: Find entities by various criteria
  • openNodes: Retrieve entities and their relationships
  • readGraph: Access the complete knowledge graph
  • getKnowledgeGraphStats: View statistics about your knowledge base

Core Concepts

Entities

Entities are the primary nodes in the knowledge graph, containing:

  • A unique name (identifier)
  • An entity type (e.g., "PERSON", "CONCEPT")
  • A list of observations (contextual information)

Example:

{
  "name": "Machine Learning",
  "entityType": "CONCEPT",
  "observations": [
    "Subset of artificial intelligence",
    "Focuses on learning from data",
    "Used in recommendation systems"
  ]
}

Relations

Relations define connections between entities:

{
  "from": "React",
  "to": "JavaScript",
  "relationType": "BUILT_WITH"
}

Documents & Vector Search

Documents are processed through:

  1. Storage (raw text with metadata)
  2. Chunking (splitting into pieces)
  3. Embedding (converting to vectors)
  4. Linking (associating with entities)

This enables hybrid search that combines semantic matching with conceptual relationships.

Usage Examples

Here's a typical workflow for building and querying a knowledge base:

// Store a document
await storeDocument({
  id: "ml_intro",
  content: "Machine learning is a subset of AI...",
  metadata: { type: "educational", topic: "ML" }
});

// Process the document
await chunkDocument({ documentId: "ml_intro" });
await embedChunks({ documentId: "ml_intro" });

// Extract and create entities
const terms = await extractTerms({ documentId: "ml_intro" });
await createEntities({
  entities: [
    {
      name: "Machine Learning",
      entityType: "CONCEPT",
      observations: ["Subset of artificial intelligence", "Learns from data"]
    }
  ]
});

// Search with hybrid approach
const results = await hybridSearch({
  query: "artificial intelligence applications",
  limit: 10,
  useGraph: true
});

System Prompt Recommendations

For optimal memory utilization, consider using this system prompt:

You have access to a RAG-enabled memory system with knowledge graph capabilities. Follow these guidelines:

1. **Information Storage**:
   - Store important documents using the document management tools
   - Create entities for people, concepts, organizations, and technologies
   - Build relationships between related concepts

2. **Information Retrieval**:
   - Use hybrid search for comprehensive information retrieval
   - Leverage both semantic similarity and graph relationships
   - Search entities before creating duplicates

3. **Memory Maintenance**:
   - Add observations to enrich entity context
   - Link documents to relevant entities for better discoverability
   - Use statistics to monitor knowledge base growth

4. **Processing Workflow**:
   - Store → Chunk → Embed → Extract → Link
   - Always process documents completely for best search results

Environment Variables

  • MEMORY_DB_PATH: Path to the SQLite database file (default: memory.db in the server directory)

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

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

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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