collective-memory-mcp 0.6.4 → 0.7.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.
package/README.md CHANGED
@@ -1,23 +1,35 @@
1
1
  # Collective Memory MCP Server
2
2
 
3
- A persistent, graph-based memory system with **vector search** that enables AI agents to document their work and learn from each other's experiences. This system transforms ephemeral agent interactions into a searchable knowledge base of structural patterns, solutions, and methodologies.
3
+ > A persistent, graph-based memory system with vector search that enables AI agents to document their work and learn from each other's experiences.
4
+
5
+ [![npm version](https://badge.fury.io/js/collective-memory-mcp.svg)](https://www.npmjs.org/package/collective-memory-mcp)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ---
4
9
 
5
10
  ## Overview
6
11
 
7
- The Collective Memory System is designed for multi-agent environments where agents need to:
12
+ Collective Memory transforms ephemeral agent interactions into a searchable knowledge base. It enables AI agents working across multiple projects to:
13
+
14
+ - **Document** their completed work for future reference
15
+ - **Discover** how similar tasks were solved using vector search
16
+ - **Learn** from structural patterns and approaches of other agents
17
+ - **Organize** knowledge by project for multi-codebase workflows
8
18
 
9
- - Document their completed work for future reference
10
- - Discover how similar tasks were solved previously using **vector search**
11
- - Learn from the structural patterns and approaches of other agents
12
- - Coordinate across parallel executions without duplicating effort
19
+ ---
13
20
 
14
- ## Key Features
21
+ ## Features
15
22
 
16
- - **Vector Search** - TF-IDF based search finds conceptually similar content even when keywords differ
17
- - **Knowledge Graph** - Entities and relations capture complex relationships
18
- - **Ranked Results** - Similarity scores help identify the most relevant past work
19
- - **Zero Configuration** - Works out of the box, no external dependencies or API keys needed
20
- - **Pure JavaScript** - No native dependencies, works completely offline
23
+ | Feature | Description |
24
+ |---------|-------------|
25
+ | **Vector Search** | TF-IDF based search finds conceptually similar content even when keywords differ |
26
+ | **Knowledge Graph** | Entities and relations capture complex relationships |
27
+ | **Ranked Results** | Similarity scores help identify the most relevant past work |
28
+ | **Multi-Project** | Organize and search knowledge across multiple codebases |
29
+ | **Zero Configuration** | Works out of the box, no external dependencies or API keys needed |
30
+ | **Pure JavaScript** | No native dependencies, works completely offline |
31
+
32
+ ---
21
33
 
22
34
  ## Installation
23
35
 
@@ -25,9 +37,16 @@ The Collective Memory System is designed for multi-agent environments where agen
25
37
  npx collective-memory-mcp
26
38
  ```
27
39
 
28
- ## Claude Desktop Configuration
40
+ ---
41
+
42
+ ## Configuration
29
43
 
30
- Add to your Claude Desktop MCP configuration (`~/.config/Claude/claude_desktop_config.json` on macOS/Linux or `%APPDATA%\Claude\claude_desktop_config.json` on Windows):
44
+ ### Claude Desktop
45
+
46
+ Add to your Claude Desktop MCP configuration:
47
+
48
+ **macOS/Linux:** `~/.config/Claude/claude_desktop_config.json`
49
+ **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
31
50
 
32
51
  ```json
33
52
  {
@@ -35,110 +54,193 @@ Add to your Claude Desktop MCP configuration (`~/.config/Claude/claude_desktop_c
35
54
  "collective-memory": {
36
55
  "command": "npx",
37
56
  "args": ["-y", "collective-memory-mcp"]
57
+ },
58
+ "sequential-thinking": {
59
+ "command": "npx",
60
+ "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
38
61
  }
39
62
  }
40
63
  }
41
64
  ```
42
65
 
43
- The `-y` flag suppresses the npx prompt and auto-installs the latest version.
66
+ > **Note:** The `sequential-thinking` MCP server is required for the full workflow. The `-y` flag suppresses the npx prompt and auto-installs the latest version.
44
67
 
45
- ## System Prompt (Required)
68
+ ---
46
69
 
47
- This MCP server does NOT automatically inject its prompts into new chats. You MUST manually add this to your Claude/AI system prompt:
70
+ ## System Prompt
71
+
72
+ Add this to your AI system prompt:
48
73
 
49
74
  ```
50
75
  You have access to a Collective Memory MCP Server that stores knowledge from previous tasks.
51
76
 
52
- BEFORE starting work, search for similar past tasks using:
53
- - search_collective_memory (vector search - understands meaning, not just keywords)
54
- - find_similar_procedures (finds similar tasks with full implementation details)
77
+ ## SEQUENTIAL THINKING (ALWAYS)
78
+ - Call `mcp_sequential-thinking_sequentialthinking` as your FIRST action in EVERY response
79
+ - Use it to analyze the request, plan your approach, and organize your thoughts
80
+ - Continue calling it until `nextThoughtNeeded: false`
81
+ - This applies to ALL responses: questions, tasks, explanations, debugging, etc.
82
+ - NO EXCEPTIONS - even simple questions benefit from structured thinking
55
83
 
56
- The search uses TF-IDF vector embeddings, so it finds relevant content even when different
57
- terminology is used. Results are ranked by similarity score.
84
+ ## MANDATORY WORKFLOW (Every Chat)
58
85
 
59
- AFTER completing any task (like any, it doesn't matter even if you answer a question), document it using:
60
- - record_task_completion
86
+ ### Phase 1: INIT (First response of every chat)
87
+ 1. Call `sequentialthinking` to analyze the user's request
88
+ 2. Call `getting_started` tool to load tool knowledge
89
+ 3. Acknowledge initialization complete (brief confirmation)
90
+
91
+ ### Phase 2: SEARCH (Before any task)
92
+ - Call `sequentialthinking` to formulate search strategy
93
+ - Call `search_collective_memory` OR `find_similar_procedures` with relevant query
94
+ - Review past solutions before implementing
95
+
96
+ ### Phase 3: WORK
97
+ - Call `sequentialthinking` before each major step
98
+ - Apply learnings from Phase 2
99
+
100
+ ### Phase 4: DOCUMENT (After completing ANY task, including Q&A)
101
+ - Call `sequentialthinking` to summarize what was accomplished
102
+ - Call `record_task_completion` with:
103
+ - Specific observations (file paths, versions, metrics, error messages)
104
+ - NO vague statements like "works well" or "fixed bugs"
105
+
106
+ ## ENFORCEMENT
107
+ - Sequential thinking is NON-NEGOTIABLE on EVERY response
108
+ - Phase 1 is NON-NEGOTIABLE on first response of chat
109
+ - Phase 4 applies to ALL completions, no exceptions
110
+ - If you skip any phase, acknowledge the violation and correct immediately
111
+
112
+ ## Available Tools
113
+
114
+ BEFORE starting work, search for similar past tasks using:
115
+ - `search_collective_memory` - Vector search (understands meaning, not just keywords)
116
+ - `find_similar_procedures` - Find similar tasks with full implementation details
117
+
118
+ AFTER completing any task (including answering questions), document it using:
119
+ - `record_task_completion`
61
120
 
62
121
  When writing observations, be SPECIFIC and include facts like file paths, versions,
63
122
  metrics, and error messages. Avoid vague statements like "works well" or "fixed bugs".
64
123
 
65
- When to use getPrompt():
66
- - Use listPrompts() at the start of a new chat to see all available prompt templates
67
- - Call getPrompt(name) when you need a specific predefined prompt (e.g., "getting-started")
68
- - Fetch prompts proactively - don't wait for the user to request them
69
- - This is especially important in new chats where context hasn't been established yet
124
+ In new chats, call `getting_started` tool to learn about the system.
125
+ Use `task_documentation_guide`, `search_workflow_guide`, and `observation_best_practices` for detailed guidance.
70
126
  ```
71
127
 
72
- **Important:** This system prompt must be manually configured in your AI client. The MCP protocol does not support automatic prompt injection on connection.
128
+ ---
73
129
 
74
- ## How Vector Search Works
130
+ ## How It Works
75
131
 
76
- This system uses **TF-IDF (Term Frequency-Inverse Document Frequency)** vector search:
132
+ ### Vector Search
133
+
134
+ Uses **TF-IDF (Term Frequency-Inverse Document Frequency)** for semantic-like search:
77
135
 
78
136
  - Tokenizes text into meaningful terms
79
137
  - Calculates term importance based on frequency
80
138
  - Uses cosine similarity to rank results
81
139
  - Works entirely offline with no external dependencies
82
140
 
83
- No configuration needed - it just works!
141
+ ```
142
+ Query: "login" → Finds: "authentication", "JWT", "OAuth", "user session"
143
+ Query: "slow API" → Finds: "performance", "optimization", "caching", "database index"
144
+ ```
145
+
146
+ ### Multi-Project Support
147
+
148
+ Organize knowledge by project when working on multiple codebases:
149
+
150
+ ```javascript
151
+ // Record a task with project context
152
+ await record_task_completion({
153
+ project: "my-app",
154
+ task_name: "Task_Add_JWT_Auth",
155
+ observations: ["Added JWT middleware at /src/auth/jwt.js"]
156
+ })
157
+
158
+ // Search within a specific project
159
+ await search_collective_memory({
160
+ project: "my-app",
161
+ query: "authentication"
162
+ })
163
+ ```
164
+
165
+ ---
84
166
 
85
167
  ## Entity Types
86
168
 
87
169
  | Type | Description |
88
170
  |------|-------------|
89
- | `agent` | Represents an autonomous AI agent |
171
+ | `agent` | An autonomous AI agent |
90
172
  | `task` | A unit of work completed by an agent |
91
173
  | `structure` | Architectural decisions or code patterns |
92
174
  | `artifact` | Concrete outputs like files or configurations |
93
175
  | `session` | A continuous work context grouping related tasks |
176
+ | `project` | Groups tasks by project/repository |
177
+
178
+ ---
94
179
 
95
180
  ## Relation Types
96
181
 
97
- | Type | From -> To | Description |
182
+ | Type | From To | Description |
98
183
  |------|------------|-------------|
99
- | `executed_by` | Task -> Agent | Links task to executing agent |
100
- | `created` | Task -> Artifact | Task produced an artifact |
101
- | `modified` | Task -> Structure | Task changed existing structure |
102
- | `documented` | Task -> Structure | Task defined a structure |
103
- | `depends_on` | Task -> Task | Task dependency |
104
- | `part_of` | Task -> Session | Groups tasks in session |
105
- | `similar_to` | Task -> Task | Similar problem solutions |
106
- | `uses` | Task -> Artifact | Task consumed artifact |
107
- | `implements` | Artifact -> Structure | Artifact implements structure |
184
+ | `executed_by` | Task Agent | Links task to executing agent |
185
+ | `created` | Task Artifact | Task produced an artifact |
186
+ | `modified` | Task Structure | Task changed existing structure |
187
+ | `documented` | Task Structure | Task defined a structure |
188
+ | `depends_on` | Task Task | Task dependency |
189
+ | `part_of` | Task Session/Project | Groups tasks in session or project |
190
+ | `similar_to` | Task Task | Similar problem solutions |
191
+ | `uses` | Task Artifact | Task consumed artifact |
192
+ | `implements` | Artifact Structure | Artifact implements structure |
193
+
194
+ ---
108
195
 
109
196
  ## API Tools
110
197
 
198
+ ### Core Workflow
199
+
200
+ | Tool | Purpose |
201
+ |------|---------|
202
+ | `record_task_completion` | **PRIMARY** - Document completed work with full context |
203
+ | `search_collective_memory` | Vector search with ranked results |
204
+ | `find_similar_procedures` | Find similar tasks with full implementation details |
205
+
111
206
  ### Entity Management
112
207
 
113
- - **create_entities** - Create multiple new entities
114
- - **delete_entities** - Remove entities with cascade delete
115
- - **add_observations** - Add observations to existing entities
116
- - **delete_observations** - Remove specific observations
208
+ | Tool | Purpose |
209
+ |------|---------|
210
+ | `create_entities` | Create multiple new entities |
211
+ | `delete_entities` | Remove entities with cascade delete |
212
+ | `add_observations` | Add observations to existing entities |
213
+ | `delete_observations` | Remove specific observations |
117
214
 
118
215
  ### Relation Management
119
216
 
120
- - **create_relations** - Create directed relations between entities
121
- - **delete_relations** - Remove specific relations
217
+ | Tool | Purpose |
218
+ |------|---------|
219
+ | `create_relations` | Create directed relations between entities |
220
+ | `delete_relations` | Remove specific relations |
122
221
 
123
- ### Query & Search
222
+ ### Query & Guidance
124
223
 
125
- - **read_graph** - Read entire knowledge graph
126
- - **search_collective_memory** - Vector search with ranked results
127
- - **open_nodes** - Retrieve specific nodes by name
224
+ | Tool | Purpose |
225
+ |------|---------|
226
+ | `read_graph` | Read entire knowledge graph |
227
+ | `open_nodes` | Retrieve specific nodes by name |
228
+ | `getting_started` | Introduction to the system |
229
+ | `task_documentation_guide` | How to document completed tasks |
230
+ | `search_workflow_guide` | How to search and learn from past work |
231
+ | `observation_best_practices` | How to write effective observations |
128
232
 
129
- ### Agent Workflow
233
+ ---
130
234
 
131
- - **record_task_completion** - Primary tool for documenting completed work
132
- - **find_similar_procedures** - Find similar tasks with full implementation details
133
-
134
- ## Example Usage
235
+ ## Examples
135
236
 
136
237
  ### Recording a Task Completion
137
238
 
138
239
  ```javascript
139
- await session.callTool("record_task_completion", {
240
+ await record_task_completion({
140
241
  agent_name: "Agent_Backend_Developer",
141
- task_name: "Task_Implement_Pagination",
242
+ task_name: "Task_Implement_Pagination_20241224",
243
+ project: "my-backend-api",
142
244
  task_type: "implementation",
143
245
  description: "Added cursor-based pagination to all list endpoints",
144
246
  observations: [
@@ -146,21 +248,19 @@ await session.callTool("record_task_completion", {
146
248
  "Cursor encodes last_seen_id and last_seen_timestamp",
147
249
  "Default page size: 50 items, max: 200"
148
250
  ],
149
- created_artifacts: [
150
- {
151
- name: "Artifact_Pagination_Middleware",
152
- observations: ["Located at /src/middleware/pagination.js"]
153
- }
154
- ],
155
- session_id: "Session_API_Performance_Optimization"
251
+ created_artifacts: [{
252
+ name: "Artifact_Pagination_Middleware",
253
+ observations: ["Located at /src/middleware/pagination.js"]
254
+ }]
156
255
  });
157
256
  ```
158
257
 
159
- ### Finding Similar Procedures (Vector Search)
258
+ ### Finding Similar Procedures
160
259
 
161
260
  ```javascript
162
- const result = await session.callTool("find_similar_procedures", {
163
- query: "authentication implementation"
261
+ const result = await find_similar_procedures({
262
+ query: "authentication implementation",
263
+ project: "my-backend-api" // Optional: filter by project
164
264
  });
165
265
 
166
266
  // Returns ranked results with similarity scores:
@@ -173,37 +273,26 @@ const result = await session.callTool("find_similar_procedures", {
173
273
  // }
174
274
  ```
175
275
 
176
- ### Searching the Collective Memory
177
-
178
- ```javascript
179
- const result = await session.callTool("search_collective_memory", {
180
- query: "database optimization"
181
- });
182
-
183
- // Returns matching entities with similarity scores
184
- ```
276
+ ---
185
277
 
186
278
  ## Database
187
279
 
188
- The server uses JSON file storage for persistence. Data is stored at:
280
+ Data is stored locally at:
189
281
 
190
282
  ```
191
- ~/.collective-memory/memory.json # Knowledge graph data
283
+ ~/.collective-memory/memory.json
192
284
  ```
193
285
 
194
- ## Vector Search Benefits
286
+ No database setup required. Everything is stored as JSON.
195
287
 
196
- | Traditional Keyword Search | TF-IDF Vector Search |
197
- |---------------------------|---------------------|
198
- | Exact word matching required | Finds related terms automatically |
199
- | No relevance ranking | Results ranked by similarity score (0-1) |
200
- | "login" misses "authentication" | "login" finds "authentication", "JWT", "OAuth" |
201
- | High false-positive rate | More precise, relevant results |
288
+ ---
202
289
 
203
290
  ## Requirements
204
291
 
205
292
  - Node.js 18+
206
293
 
294
+ ---
295
+
207
296
  ## License
208
297
 
209
298
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "collective-memory-mcp",
3
- "version": "0.6.4",
3
+ "version": "0.7.0",
4
4
  "description": "A persistent, graph-based memory system for AI agents with TF-IDF vector search (MCP Server)",
5
5
  "type": "module",
6
6
  "main": "src/server.js",
package/src/models.js CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Valid entity types
7
7
  */
8
- export const ENTITY_TYPES = ["agent", "task", "structure", "artifact", "session"];
8
+ export const ENTITY_TYPES = ["agent", "task", "structure", "artifact", "session", "project"];
9
9
 
10
10
  /**
11
11
  * Valid relation types