rag-memory-epf-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +292 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +1654 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/src/migrations/migration-manager.d.ts +28 -0
  7. package/dist/src/migrations/migration-manager.d.ts.map +1 -0
  8. package/dist/src/migrations/migration-manager.js +111 -0
  9. package/dist/src/migrations/migration-manager.js.map +1 -0
  10. package/dist/src/migrations/migrations.d.ts +3 -0
  11. package/dist/src/migrations/migrations.d.ts.map +1 -0
  12. package/dist/src/migrations/migrations.js +181 -0
  13. package/dist/src/migrations/migrations.js.map +1 -0
  14. package/dist/src/tools/graph-query-tools.d.ts +16 -0
  15. package/dist/src/tools/graph-query-tools.d.ts.map +1 -0
  16. package/dist/src/tools/graph-query-tools.js +452 -0
  17. package/dist/src/tools/graph-query-tools.js.map +1 -0
  18. package/dist/src/tools/knowledge-graph-tools.d.ts +16 -0
  19. package/dist/src/tools/knowledge-graph-tools.d.ts.map +1 -0
  20. package/dist/src/tools/knowledge-graph-tools.js +482 -0
  21. package/dist/src/tools/knowledge-graph-tools.js.map +1 -0
  22. package/dist/src/tools/migration-tools.d.ts +3 -0
  23. package/dist/src/tools/migration-tools.d.ts.map +1 -0
  24. package/dist/src/tools/migration-tools.js +172 -0
  25. package/dist/src/tools/migration-tools.js.map +1 -0
  26. package/dist/src/tools/rag-tools.d.ts +20 -0
  27. package/dist/src/tools/rag-tools.d.ts.map +1 -0
  28. package/dist/src/tools/rag-tools.js +524 -0
  29. package/dist/src/tools/rag-tools.js.map +1 -0
  30. package/dist/src/tools/tool-registry.d.ts +82 -0
  31. package/dist/src/tools/tool-registry.d.ts.map +1 -0
  32. package/dist/src/tools/tool-registry.js +185 -0
  33. package/dist/src/tools/tool-registry.js.map +1 -0
  34. package/dist/src/tools/types.d.ts +34 -0
  35. package/dist/src/tools/types.d.ts.map +1 -0
  36. package/dist/src/tools/types.js +2 -0
  37. package/dist/src/tools/types.js.map +1 -0
  38. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,292 @@
1
+ # rag-memory-mcp
2
+
3
+ [![npm version](https://img.shields.io/npm/v/rag-memory-mcp)](https://www.npmjs.com/package/rag-memory-mcp)
4
+ [![npm downloads](https://img.shields.io/npm/dm/rag-memory-mcp)](https://www.npmjs.com/package/rag-memory-mcp)
5
+ [![GitHub license](https://img.shields.io/github/license/ttommyth/rag-memory-mcp)](https://github.com/ttommyth/rag-memory-mcp/blob/main/LICENSE)
6
+ [![Platforms](https://img.shields.io/badge/Platform-Windows%20%7C%20macOS%20%7C%20Linux-blue)](https://github.com/ttommyth/rag-memory-mcp)
7
+ [![GitHub last commit](https://img.shields.io/github/last-commit/ttommyth/rag-memory-mcp)](https://github.com/ttommyth/rag-memory-mcp/commits/main)
8
+
9
+ 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.
10
+
11
+ **Inspired by:** [Knowledge Graph Memory Server](https://github.com/modelcontextprotocol/servers/tree/main/src/memory) from the Model Context Protocol project.
12
+
13
+ **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.
14
+
15
+ ## ✨ Key Features
16
+
17
+ - **🧠 Knowledge Graph Memory**: Persistent entities, relationships, and observations
18
+ - **🔍 Vector Search**: Semantic similarity search using sentence transformers
19
+ - **📄 Document Processing**: RAG-enabled document chunking and embedding
20
+ - **🔗 Hybrid Search**: Combines vector similarity with graph traversal
21
+ - **⚡ SQLite Backend**: Fast local storage with sqlite-vec for vector operations
22
+ - **🎯 Entity Extraction**: Automatic term extraction from documents
23
+
24
+ ## Tools
25
+
26
+ This server provides comprehensive memory management through the Model Context Protocol (MCP):
27
+
28
+ ### 📚 Document Management
29
+ - `storeDocument`: Store documents with metadata for processing
30
+ - `chunkDocument`: Create text chunks with configurable parameters
31
+ - `embedChunks`: Generate vector embeddings for semantic search
32
+ - `extractTerms`: Extract potential entity terms from documents
33
+ - `linkEntitiesToDocument`: Create explicit entity-document associations
34
+ - `deleteDocuments`: Remove documents and associated data
35
+ - `listDocuments`: View all stored documents with metadata
36
+
37
+ ### 🧠 Knowledge Graph
38
+ - `createEntities`: Create new entities with observations and types
39
+ - `createRelations`: Establish relationships between entities
40
+ - `addObservations`: Add contextual information to existing entities
41
+ - `deleteEntities`: Remove entities and their relationships
42
+ - `deleteRelations`: Remove specific relationships
43
+ - `deleteObservations`: Remove specific observations from entities
44
+
45
+ ### 🔍 Search & Retrieval
46
+ - `hybridSearch`: Advanced search combining vector similarity and graph traversal
47
+ - `searchNodes`: Find entities by name, type, or observation content
48
+ - `openNodes`: Retrieve specific entities and their relationships
49
+ - `readGraph`: Get complete knowledge graph structure
50
+
51
+ ### 📊 Analytics
52
+ - `getKnowledgeGraphStats`: Comprehensive statistics about the knowledge base
53
+
54
+ ## Usage Scenarios
55
+
56
+ This server is ideal for scenarios requiring intelligent memory and document understanding:
57
+
58
+ - **Research and Documentation**: Store, process, and intelligently retrieve research papers
59
+ - **Knowledge Base Construction**: Build interconnected knowledge from documents
60
+ - **Conversational Memory**: Remember context across chat sessions with semantic understanding
61
+ - **Content Analysis**: Extract and relate concepts from large document collections
62
+ - **Intelligent Assistance**: Provide contextually aware responses based on stored knowledge
63
+
64
+ ## Client Configuration
65
+
66
+ This section explains how to configure MCP clients to use the `rag-memory-mcp` server.
67
+
68
+ ### Usage with Claude Desktop / Cursor
69
+
70
+ Add the following configuration to your `claude_desktop_config.json` (Claude Desktop) or `mcp.json` (Cursor):
71
+
72
+ ```json
73
+ {
74
+ "mcpServers": {
75
+ "rag-memory": {
76
+ "command": "npx",
77
+ "args": ["-y", "rag-memory-mcp"]
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ **With specific version:**
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "rag-memory": {
88
+ "command": "npx",
89
+ "args": ["-y", "rag-memory-mcp@1.0.0"]
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ **With custom database path:**
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "rag-memory": {
100
+ "command": "npx",
101
+ "args": ["-y", "rag-memory-mcp"],
102
+ "env": {
103
+ "MEMORY_DB_PATH": "/path/to/custom/memory.db"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Usage with VS Code
111
+
112
+ Add the following configuration to your User Settings (JSON) file or `.vscode/mcp.json`:
113
+
114
+ ```json
115
+ {
116
+ "mcp": {
117
+ "servers": {
118
+ "rag-memory-mcp": {
119
+ "command": "npx",
120
+ "args": ["-y", "rag-memory-mcp"]
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ ## Core Concepts
128
+
129
+ ### Entities
130
+ Entities are the primary nodes in the knowledge graph. Each entity has:
131
+ - A unique name (identifier)
132
+ - An entity type (e.g., "PERSON", "CONCEPT", "TECHNOLOGY")
133
+ - A list of observations (contextual information)
134
+
135
+ Example:
136
+ ```json
137
+ {
138
+ "name": "Machine Learning",
139
+ "entityType": "CONCEPT",
140
+ "observations": [
141
+ "Subset of artificial intelligence",
142
+ "Focuses on learning from data",
143
+ "Used in recommendation systems"
144
+ ]
145
+ }
146
+ ```
147
+
148
+ ### Relations
149
+ Relations define directed connections between entities, describing how they interact:
150
+
151
+ Example:
152
+ ```json
153
+ {
154
+ "from": "React",
155
+ "to": "JavaScript",
156
+ "relationType": "BUILT_WITH"
157
+ }
158
+ ```
159
+
160
+ ### Observations
161
+ Observations are discrete pieces of information about entities:
162
+ - Stored as strings
163
+ - Attached to specific entities
164
+ - Can be added or removed independently
165
+ - Should be atomic (one fact per observation)
166
+
167
+ ### Documents & Vector Search
168
+ Documents are processed through:
169
+ 1. **Storage**: Raw text with metadata
170
+ 2. **Chunking**: Split into manageable pieces
171
+ 3. **Embedding**: Convert to vector representations
172
+ 4. **Linking**: Associate with relevant entities
173
+
174
+ This enables **hybrid search** that combines:
175
+ - Vector similarity (semantic matching)
176
+ - Graph traversal (conceptual relationships)
177
+
178
+ ## Environment Variables
179
+
180
+ - `MEMORY_DB_PATH`: Path to the SQLite database file (default: `memory.db` in the server directory)
181
+
182
+ ## Development Setup
183
+
184
+ This section is for developers looking to modify or contribute to the server.
185
+
186
+ ### Prerequisites
187
+ - **Node.js**: Check `package.json` for version compatibility
188
+ - **npm**: Used for package management
189
+
190
+ ### Installation (Developers)
191
+
192
+ 1. Clone the repository:
193
+ ```bash
194
+ git clone https://github.com/ttommyth/rag-memory-mcp.git
195
+ cd rag-memory-mcp
196
+ ```
197
+
198
+ 2. Install dependencies:
199
+ ```bash
200
+ npm install
201
+ ```
202
+
203
+ ### Building
204
+ ```bash
205
+ npm run build
206
+ ```
207
+
208
+ ### Running (Development)
209
+ ```bash
210
+ npm run watch # For development with auto-rebuild
211
+ ```
212
+
213
+ ## Development Commands
214
+
215
+ - **Build**: `npm run build`
216
+ - **Watch**: `npm run watch`
217
+ - **Prepare**: `npm run prepare`
218
+
219
+ ## Usage Example
220
+
221
+ Here's a typical workflow for building and querying a knowledge base:
222
+
223
+ ```javascript
224
+ // 1. Store a document
225
+ await storeDocument({
226
+ id: "ml_intro",
227
+ content: "Machine learning is a subset of AI...",
228
+ metadata: { type: "educational", topic: "ML" }
229
+ });
230
+
231
+ // 2. Process the document
232
+ await chunkDocument({ documentId: "ml_intro" });
233
+ await embedChunks({ documentId: "ml_intro" });
234
+
235
+ // 3. Extract and create entities
236
+ const terms = await extractTerms({ documentId: "ml_intro" });
237
+ await createEntities({
238
+ entities: [
239
+ {
240
+ name: "Machine Learning",
241
+ entityType: "CONCEPT",
242
+ observations: ["Subset of artificial intelligence", "Learns from data"]
243
+ }
244
+ ]
245
+ });
246
+
247
+ // 4. Search with hybrid approach
248
+ const results = await hybridSearch({
249
+ query: "artificial intelligence applications",
250
+ limit: 10,
251
+ useGraph: true
252
+ });
253
+ ```
254
+
255
+ ## System Prompt Suggestions
256
+
257
+ For optimal memory utilization, consider using this system prompt:
258
+
259
+ ```
260
+ You have access to a RAG-enabled memory system with knowledge graph capabilities. Follow these guidelines:
261
+
262
+ 1. **Information Storage**:
263
+ - Store important documents using the document management tools
264
+ - Create entities for people, concepts, organizations, and technologies
265
+ - Build relationships between related concepts
266
+
267
+ 2. **Information Retrieval**:
268
+ - Use hybrid search for comprehensive information retrieval
269
+ - Leverage both semantic similarity and graph relationships
270
+ - Search entities before creating duplicates
271
+
272
+ 3. **Memory Maintenance**:
273
+ - Add observations to enrich entity context
274
+ - Link documents to relevant entities for better discoverability
275
+ - Use statistics to monitor knowledge base growth
276
+
277
+ 4. **Processing Workflow**:
278
+ - Store → Chunk → Embed → Extract → Link
279
+ - Always process documents completely for best search results
280
+ ```
281
+
282
+ ## Contributing
283
+
284
+ Contributions are welcome! Please follow standard development practices and ensure all tests pass before submitting pull requests.
285
+
286
+ ## License
287
+
288
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
289
+
290
+ ---
291
+
292
+ **Built with**: TypeScript, SQLite, sqlite-vec, Hugging Face Transformers, Model Context Protocol SDK
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}