Leverages Hugging Face Transformers for document processing, embeddings generation, and semantic search capabilities
Runs as a Node.js application, providing the runtime environment for the MCP server
Uses SQLite with sqlite-vec for fast local storage and vector operations to maintain the knowledge graph and document embeddings
Built with TypeScript, offering type safety and modern language features for the server implementation
rag-memory-mcp
An advanced MCP server for RAG-enabled memory through a knowledge graph with vector search capabilities. This server extends the basic memory concepts with semantic search, document processing, and hybrid retrieval for more intelligent memory management.
Inspired by: Knowledge Graph Memory Server from the Model Context Protocol project.
Note: This server is designed to run locally alongside MCP clients (e.g., Claude Desktop, VS Code) and requires local file system access for database storage.
✨ Key Features
- 🧠 Knowledge Graph Memory: Persistent entities, relationships, and observations
- 🔍 Vector Search: Semantic similarity search using sentence transformers
- 📄 Document Processing: RAG-enabled document chunking and embedding
- 🔗 Hybrid Search: Combines vector similarity with graph traversal
- ⚡ SQLite Backend: Fast local storage with sqlite-vec for vector operations
- 🎯 Entity Extraction: Automatic term extraction from documents
Tools
This server provides comprehensive memory management through the Model Context Protocol (MCP):
📚 Document Management
storeDocument
: Store documents with metadata for processingchunkDocument
: Create text chunks with configurable parametersembedChunks
: Generate vector embeddings for semantic searchextractTerms
: Extract potential entity terms from documentslinkEntitiesToDocument
: Create explicit entity-document associationsdeleteDocuments
: Remove documents and associated datalistDocuments
: View all stored documents with metadata
🧠 Knowledge Graph
createEntities
: Create new entities with observations and typescreateRelations
: Establish relationships between entitiesaddObservations
: Add contextual information to existing entitiesdeleteEntities
: Remove entities and their relationshipsdeleteRelations
: Remove specific relationshipsdeleteObservations
: Remove specific observations from entities
🔍 Search & Retrieval
hybridSearch
: Advanced search combining vector similarity and graph traversalsearchNodes
: Find entities by name, type, or observation contentopenNodes
: Retrieve specific entities and their relationshipsreadGraph
: Get complete knowledge graph structure
📊 Analytics
getKnowledgeGraphStats
: Comprehensive statistics about the knowledge base
Usage Scenarios
This server is ideal for scenarios requiring intelligent memory and document understanding:
- Research and Documentation: Store, process, and intelligently retrieve research papers
- Knowledge Base Construction: Build interconnected knowledge from documents
- Conversational Memory: Remember context across chat sessions with semantic understanding
- Content Analysis: Extract and relate concepts from large document collections
- Intelligent Assistance: Provide contextually aware responses based on stored knowledge
Client Configuration
This section explains how to configure MCP clients to use the rag-memory-mcp
server.
Usage with Claude Desktop / Cursor
Add the following configuration to your claude_desktop_config.json
(Claude Desktop) or mcp.json
(Cursor):
With specific version:
With custom database path:
Usage with VS Code
Add the following configuration to your User Settings (JSON) file or .vscode/mcp.json
:
Core Concepts
Entities
Entities are the primary nodes in the knowledge graph. Each entity has:
- A unique name (identifier)
- An entity type (e.g., "PERSON", "CONCEPT", "TECHNOLOGY")
- A list of observations (contextual information)
Example:
Relations
Relations define directed connections between entities, describing how they interact:
Example:
Observations
Observations are discrete pieces of information about entities:
- Stored as strings
- Attached to specific entities
- Can be added or removed independently
- Should be atomic (one fact per observation)
Documents & Vector Search
Documents are processed through:
- Storage: Raw text with metadata
- Chunking: Split into manageable pieces
- Embedding: Convert to vector representations
- Linking: Associate with relevant entities
This enables hybrid search that combines:
- Vector similarity (semantic matching)
- Graph traversal (conceptual relationships)
Environment Variables
MEMORY_DB_PATH
: Path to the SQLite database file (default:memory.db
in the server directory)
Development Setup
This section is for developers looking to modify or contribute to the server.
Prerequisites
- Node.js: Check
package.json
for version compatibility - npm: Used for package management
Installation (Developers)
- Clone the repository:
- Install dependencies:
Building
Running (Development)
Development Commands
- Build:
npm run build
- Watch:
npm run watch
- Prepare:
npm run prepare
Usage Example
Here's a typical workflow for building and querying a knowledge base:
System Prompt Suggestions
For optimal memory utilization, consider using this system prompt:
Contributing
Contributions are welcome! Please follow standard development practices and ensure all tests pass before submitting pull requests.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Built with: TypeScript, SQLite, sqlite-vec, Hugging Face Transformers, Model Context Protocol SDK
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
An advanced MCP server providing RAG-enabled memory through a knowledge graph with vector search capabilities, enabling intelligent information storage, semantic retrieval, and document processing.
Related MCP Servers
- -securityAlicense-qualityThis project is based on the Knowledge Graph Memory Server from the MCP servers repository and retains its core functionality.Last updated -44107TypeScriptMIT License
- AsecurityAlicenseAqualityA high-performance MCP server utilizing libSQL for persistent memory and vector search capabilities, enabling efficient entity management and semantic knowledge storage.Last updated -66055TypeScriptMIT License
- AsecurityAlicenseAqualityA customized MCP memory server that enables creation and management of a knowledge graph with features like custom memory paths and timestamping for capturing interactions via language models.Last updated -112JavaScriptMIT License
- -securityAlicense-qualityEnhances the MCP memory server by implementing PouchDB for robust document storage and enabling the creation and management of a knowledge graph that captures interactions via language models.Last updated -JavaScriptMIT License