collective-memory-mcp 0.6.5 → 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 +178 -93
- package/package.json +1 -1
- package/src/models.js +1 -1
- package/src/server.js +631 -88
package/README.md
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
# Collective Memory MCP Server
|
|
2
2
|
|
|
3
|
-
A persistent, graph-based memory system with
|
|
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
|
+
[](https://www.npmjs.org/package/collective-memory-mcp)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
---
|
|
4
9
|
|
|
5
10
|
## Overview
|
|
6
11
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
21
|
+
## Features
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Configuration
|
|
43
|
+
|
|
44
|
+
### Claude Desktop
|
|
29
45
|
|
|
30
|
-
Add to your Claude Desktop MCP configuration
|
|
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,114 +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.
|
|
67
|
+
|
|
68
|
+
---
|
|
44
69
|
|
|
45
|
-
## System Prompt
|
|
70
|
+
## System Prompt
|
|
46
71
|
|
|
47
|
-
|
|
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
|
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
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
|
|
83
|
+
|
|
84
|
+
## MANDATORY WORKFLOW (Every Chat)
|
|
55
85
|
|
|
56
|
-
|
|
57
|
-
|
|
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)
|
|
58
90
|
|
|
59
|
-
|
|
60
|
-
-
|
|
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
|
-
In new chats, call getting_started tool to learn about the system.
|
|
66
|
-
Use task_documentation_guide
|
|
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.
|
|
67
126
|
```
|
|
68
127
|
|
|
69
|
-
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## How It Works
|
|
70
131
|
|
|
71
|
-
|
|
132
|
+
### Vector Search
|
|
72
133
|
|
|
73
|
-
|
|
134
|
+
Uses **TF-IDF (Term Frequency-Inverse Document Frequency)** for semantic-like search:
|
|
74
135
|
|
|
75
136
|
- Tokenizes text into meaningful terms
|
|
76
137
|
- Calculates term importance based on frequency
|
|
77
138
|
- Uses cosine similarity to rank results
|
|
78
139
|
- Works entirely offline with no external dependencies
|
|
79
140
|
|
|
80
|
-
|
|
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
|
+
---
|
|
81
166
|
|
|
82
167
|
## Entity Types
|
|
83
168
|
|
|
84
169
|
| Type | Description |
|
|
85
170
|
|------|-------------|
|
|
86
|
-
| `agent` |
|
|
171
|
+
| `agent` | An autonomous AI agent |
|
|
87
172
|
| `task` | A unit of work completed by an agent |
|
|
88
173
|
| `structure` | Architectural decisions or code patterns |
|
|
89
174
|
| `artifact` | Concrete outputs like files or configurations |
|
|
90
175
|
| `session` | A continuous work context grouping related tasks |
|
|
176
|
+
| `project` | Groups tasks by project/repository |
|
|
177
|
+
|
|
178
|
+
---
|
|
91
179
|
|
|
92
180
|
## Relation Types
|
|
93
181
|
|
|
94
|
-
| Type | From
|
|
182
|
+
| Type | From → To | Description |
|
|
95
183
|
|------|------------|-------------|
|
|
96
|
-
| `executed_by` | Task
|
|
97
|
-
| `created` | Task
|
|
98
|
-
| `modified` | Task
|
|
99
|
-
| `documented` | Task
|
|
100
|
-
| `depends_on` | Task
|
|
101
|
-
| `part_of` | Task
|
|
102
|
-
| `similar_to` | Task
|
|
103
|
-
| `uses` | Task
|
|
104
|
-
| `implements` | Artifact
|
|
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
|
+
---
|
|
105
195
|
|
|
106
196
|
## API Tools
|
|
107
197
|
|
|
108
|
-
###
|
|
198
|
+
### Core Workflow
|
|
109
199
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
### Relation Management
|
|
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 |
|
|
116
205
|
|
|
117
|
-
|
|
118
|
-
- **delete_relations** - Remove specific relations
|
|
206
|
+
### Entity Management
|
|
119
207
|
|
|
120
|
-
|
|
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 |
|
|
121
214
|
|
|
122
|
-
|
|
123
|
-
- **search_collective_memory** - Vector search with ranked results
|
|
124
|
-
- **open_nodes** - Retrieve specific nodes by name
|
|
215
|
+
### Relation Management
|
|
125
216
|
|
|
126
|
-
|
|
217
|
+
| Tool | Purpose |
|
|
218
|
+
|------|---------|
|
|
219
|
+
| `create_relations` | Create directed relations between entities |
|
|
220
|
+
| `delete_relations` | Remove specific relations |
|
|
127
221
|
|
|
128
|
-
|
|
129
|
-
- **find_similar_procedures** - Find similar tasks with full implementation details
|
|
222
|
+
### Query & Guidance
|
|
130
223
|
|
|
131
|
-
|
|
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 |
|
|
132
232
|
|
|
133
|
-
|
|
134
|
-
- **task_documentation_guide** - How to document completed tasks properly
|
|
135
|
-
- **search_workflow_guide** - How to search and learn from past work
|
|
136
|
-
- **observation_best_practices** - How to write effective observations
|
|
233
|
+
---
|
|
137
234
|
|
|
138
|
-
##
|
|
235
|
+
## Examples
|
|
139
236
|
|
|
140
237
|
### Recording a Task Completion
|
|
141
238
|
|
|
142
239
|
```javascript
|
|
143
|
-
await
|
|
240
|
+
await record_task_completion({
|
|
144
241
|
agent_name: "Agent_Backend_Developer",
|
|
145
|
-
task_name: "
|
|
242
|
+
task_name: "Task_Implement_Pagination_20241224",
|
|
243
|
+
project: "my-backend-api",
|
|
146
244
|
task_type: "implementation",
|
|
147
245
|
description: "Added cursor-based pagination to all list endpoints",
|
|
148
246
|
observations: [
|
|
@@ -150,21 +248,19 @@ await session.callTool("record_task_completion", {
|
|
|
150
248
|
"Cursor encodes last_seen_id and last_seen_timestamp",
|
|
151
249
|
"Default page size: 50 items, max: 200"
|
|
152
250
|
],
|
|
153
|
-
created_artifacts: [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
],
|
|
159
|
-
session_id: "Session_API_Performance_Optimization"
|
|
251
|
+
created_artifacts: [{
|
|
252
|
+
name: "Artifact_Pagination_Middleware",
|
|
253
|
+
observations: ["Located at /src/middleware/pagination.js"]
|
|
254
|
+
}]
|
|
160
255
|
});
|
|
161
256
|
```
|
|
162
257
|
|
|
163
|
-
### Finding Similar Procedures
|
|
258
|
+
### Finding Similar Procedures
|
|
164
259
|
|
|
165
260
|
```javascript
|
|
166
|
-
const result = await
|
|
167
|
-
query: "authentication implementation"
|
|
261
|
+
const result = await find_similar_procedures({
|
|
262
|
+
query: "authentication implementation",
|
|
263
|
+
project: "my-backend-api" // Optional: filter by project
|
|
168
264
|
});
|
|
169
265
|
|
|
170
266
|
// Returns ranked results with similarity scores:
|
|
@@ -177,37 +273,26 @@ const result = await session.callTool("find_similar_procedures", {
|
|
|
177
273
|
// }
|
|
178
274
|
```
|
|
179
275
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
```javascript
|
|
183
|
-
const result = await session.callTool("search_collective_memory", {
|
|
184
|
-
query: "database optimization"
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// Returns matching entities with similarity scores
|
|
188
|
-
```
|
|
276
|
+
---
|
|
189
277
|
|
|
190
278
|
## Database
|
|
191
279
|
|
|
192
|
-
|
|
280
|
+
Data is stored locally at:
|
|
193
281
|
|
|
194
282
|
```
|
|
195
|
-
~/.collective-memory/memory.json
|
|
283
|
+
~/.collective-memory/memory.json
|
|
196
284
|
```
|
|
197
285
|
|
|
198
|
-
|
|
286
|
+
No database setup required. Everything is stored as JSON.
|
|
199
287
|
|
|
200
|
-
|
|
201
|
-
|---------------------------|---------------------|
|
|
202
|
-
| Exact word matching required | Finds related terms automatically |
|
|
203
|
-
| No relevance ranking | Results ranked by similarity score (0-1) |
|
|
204
|
-
| "login" misses "authentication" | "login" finds "authentication", "JWT", "OAuth" |
|
|
205
|
-
| High false-positive rate | More precise, relevant results |
|
|
288
|
+
---
|
|
206
289
|
|
|
207
290
|
## Requirements
|
|
208
291
|
|
|
209
292
|
- Node.js 18+
|
|
210
293
|
|
|
294
|
+
---
|
|
295
|
+
|
|
211
296
|
## License
|
|
212
297
|
|
|
213
298
|
MIT
|
package/package.json
CHANGED
package/src/models.js
CHANGED