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.
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"
}
}
}
}
Add this to your User Settings (JSON) file or .vscode/mcp.json
:
{
"mcp": {
"servers": {
"rag-memory-mcp": {
"command": "npx",
"args": ["-y", "rag-memory-mcp"]
}
}
}
}
Entities are the primary nodes in the knowledge graph, containing:
Example:
{
"name": "Machine Learning",
"entityType": "CONCEPT",
"observations": [
"Subset of artificial intelligence",
"Focuses on learning from data",
"Used in recommendation systems"
]
}
Relations define connections between entities:
{
"from": "React",
"to": "JavaScript",
"relationType": "BUILT_WITH"
}
Documents are processed through:
This enables hybrid search that combines semantic matching with conceptual relationships.
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
});
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
MEMORY_DB_PATH
: Path to the SQLite database file (default: memory.db
in the server directory)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.
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"
]
}
}
}
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.
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.