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 +178 -89
- package/package.json +1 -1
- package/src/models.js +1 -1
- package/src/server.js +864 -55
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
|
|
29
43
|
|
|
30
|
-
|
|
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
|
-
|
|
68
|
+
---
|
|
46
69
|
|
|
47
|
-
|
|
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
|
-
|
|
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
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
terminology is used. Results are ranked by similarity score.
|
|
84
|
+
## MANDATORY WORKFLOW (Every Chat)
|
|
58
85
|
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
66
|
-
|
|
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
|
-
|
|
128
|
+
---
|
|
73
129
|
|
|
74
|
-
## How
|
|
130
|
+
## How It Works
|
|
75
131
|
|
|
76
|
-
|
|
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
|
-
|
|
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` |
|
|
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
|
|
182
|
+
| Type | From → To | Description |
|
|
98
183
|
|------|------------|-------------|
|
|
99
|
-
| `executed_by` | Task
|
|
100
|
-
| `created` | Task
|
|
101
|
-
| `modified` | Task
|
|
102
|
-
| `documented` | Task
|
|
103
|
-
| `depends_on` | Task
|
|
104
|
-
| `part_of` | Task
|
|
105
|
-
| `similar_to` | Task
|
|
106
|
-
| `uses` | Task
|
|
107
|
-
| `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
|
+
---
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
121
|
-
|
|
217
|
+
| Tool | Purpose |
|
|
218
|
+
|------|---------|
|
|
219
|
+
| `create_relations` | Create directed relations between entities |
|
|
220
|
+
| `delete_relations` | Remove specific relations |
|
|
122
221
|
|
|
123
|
-
### Query &
|
|
222
|
+
### Query & Guidance
|
|
124
223
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
233
|
+
---
|
|
130
234
|
|
|
131
|
-
|
|
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
|
|
240
|
+
await record_task_completion({
|
|
140
241
|
agent_name: "Agent_Backend_Developer",
|
|
141
|
-
task_name: "
|
|
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
|
-
|
|
152
|
-
|
|
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
|
|
258
|
+
### Finding Similar Procedures
|
|
160
259
|
|
|
161
260
|
```javascript
|
|
162
|
-
const result = await
|
|
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
|
-
|
|
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
|
-
|
|
280
|
+
Data is stored locally at:
|
|
189
281
|
|
|
190
282
|
```
|
|
191
|
-
~/.collective-memory/memory.json
|
|
283
|
+
~/.collective-memory/memory.json
|
|
192
284
|
```
|
|
193
285
|
|
|
194
|
-
|
|
286
|
+
No database setup required. Everything is stored as JSON.
|
|
195
287
|
|
|
196
|
-
|
|
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
package/src/models.js
CHANGED