collective-memory-mcp 0.1.0 → 0.3.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 +104 -22
- package/package.json +12 -9
- package/src/models.js +89 -0
- package/src/server.js +793 -0
- package/src/storage.js +442 -0
- package/index.js +0 -127
package/README.md
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
# Collective Memory MCP
|
|
1
|
+
# Collective Memory MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A persistent, graph-based memory system 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.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Collective Memory System is designed for multi-agent environments where agents need to:
|
|
8
|
+
|
|
9
|
+
- Document their completed work for future reference
|
|
10
|
+
- Discover how similar tasks were solved previously
|
|
11
|
+
- Learn from the structural patterns and approaches of other agents
|
|
12
|
+
- Coordinate across parallel executions without duplicating effort
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
6
15
|
|
|
7
16
|
```bash
|
|
8
17
|
npx collective-memory-mcp
|
|
9
18
|
```
|
|
10
19
|
|
|
11
|
-
On first run, the wrapper will automatically:
|
|
12
|
-
1. Detect Python on your system
|
|
13
|
-
2. Install the `collective-memory-mcp` Python package via pip
|
|
14
|
-
3. Start the MCP server
|
|
15
|
-
|
|
16
20
|
## Claude Desktop Configuration
|
|
17
21
|
|
|
22
|
+
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):
|
|
23
|
+
|
|
18
24
|
```json
|
|
19
25
|
{
|
|
20
26
|
"mcpServers": {
|
|
21
27
|
"collective-memory": {
|
|
22
28
|
"command": "npx",
|
|
23
|
-
"args": ["-y", "collective-memory-mcp"]
|
|
24
|
-
"env": {
|
|
25
|
-
"COLLECTIVE_MEMORY_DB_PATH": "/path/to/memory.db"
|
|
26
|
-
}
|
|
29
|
+
"args": ["-y", "collective-memory-mcp"]
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
32
|
}
|
|
@@ -31,21 +34,100 @@ On first run, the wrapper will automatically:
|
|
|
31
34
|
|
|
32
35
|
The `-y` flag suppresses the npx prompt and auto-installs the latest version.
|
|
33
36
|
|
|
34
|
-
##
|
|
37
|
+
## Entity Types
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
| Type | Description |
|
|
40
|
+
|------|-------------|
|
|
41
|
+
| `agent` | Represents an autonomous AI agent |
|
|
42
|
+
| `task` | A unit of work completed by an agent |
|
|
43
|
+
| `structure` | Architectural decisions or code patterns |
|
|
44
|
+
| `artifact` | Concrete outputs like files or configurations |
|
|
45
|
+
| `session` | A continuous work context grouping related tasks |
|
|
38
46
|
|
|
39
|
-
##
|
|
47
|
+
## Relation Types
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
| Type | From -> To | Description |
|
|
50
|
+
|------|------------|-------------|
|
|
51
|
+
| `executed_by` | Task -> Agent | Links task to executing agent |
|
|
52
|
+
| `created` | Task -> Artifact | Task produced an artifact |
|
|
53
|
+
| `modified` | Task -> Structure | Task changed existing structure |
|
|
54
|
+
| `documented` | Task -> Structure | Task defined a structure |
|
|
55
|
+
| `depends_on` | Task -> Task | Task dependency |
|
|
56
|
+
| `part_of` | Task -> Session | Groups tasks in session |
|
|
57
|
+
| `similar_to` | Task -> Task | Similar problem solutions |
|
|
58
|
+
| `uses` | Task -> Artifact | Task consumed artifact |
|
|
59
|
+
| `implements` | Artifact -> Structure | Artifact implements structure |
|
|
42
60
|
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
## API Tools
|
|
62
|
+
|
|
63
|
+
### Entity Management
|
|
64
|
+
|
|
65
|
+
- **create_entities** - Create multiple new entities
|
|
66
|
+
- **delete_entities** - Remove entities with cascade delete
|
|
67
|
+
- **add_observations** - Add observations to existing entities
|
|
68
|
+
- **delete_observations** - Remove specific observations
|
|
69
|
+
|
|
70
|
+
### Relation Management
|
|
71
|
+
|
|
72
|
+
- **create_relations** - Create directed relations between entities
|
|
73
|
+
- **delete_relations** - Remove specific relations
|
|
74
|
+
|
|
75
|
+
### Query & Search
|
|
76
|
+
|
|
77
|
+
- **read_graph** - Read entire knowledge graph
|
|
78
|
+
- **search_collective_memory** - Natural language search
|
|
79
|
+
- **open_nodes** - Retrieve specific nodes by name
|
|
80
|
+
|
|
81
|
+
### Agent Workflow
|
|
82
|
+
|
|
83
|
+
- **record_task_completion** - Primary tool for documenting completed work
|
|
84
|
+
- **find_similar_procedures** - Find similar tasks with full implementation details
|
|
85
|
+
|
|
86
|
+
## Example Usage
|
|
87
|
+
|
|
88
|
+
### Recording a Task Completion
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
await session.callTool("record_task_completion", {
|
|
92
|
+
agent_name: "Agent_Backend_Developer",
|
|
93
|
+
task_name: "Task_Implement_Pagination",
|
|
94
|
+
task_type: "implementation",
|
|
95
|
+
description: "Added cursor-based pagination to all list endpoints",
|
|
96
|
+
observations: [
|
|
97
|
+
"Used keyset pagination pattern for better performance",
|
|
98
|
+
"Cursor encodes last_seen_id and last_seen_timestamp",
|
|
99
|
+
"Default page size: 50 items, max: 200"
|
|
100
|
+
],
|
|
101
|
+
created_artifacts: [
|
|
102
|
+
{
|
|
103
|
+
name: "Artifact_Pagination_Middleware",
|
|
104
|
+
observations: ["Located at /src/middleware/pagination.js"]
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
session_id: "Session_API_Performance_Optimization"
|
|
108
|
+
});
|
|
45
109
|
```
|
|
46
110
|
|
|
47
|
-
|
|
111
|
+
### Finding Similar Procedures
|
|
48
112
|
|
|
49
|
-
```
|
|
50
|
-
|
|
113
|
+
```javascript
|
|
114
|
+
const result = await session.callTool("find_similar_procedures", {
|
|
115
|
+
query: "authentication implementation"
|
|
116
|
+
});
|
|
51
117
|
```
|
|
118
|
+
|
|
119
|
+
## Database
|
|
120
|
+
|
|
121
|
+
The server uses SQLite for persistence (via `better-sqlite3`). The database is stored at:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
~/.collective-memory/memory.db
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Requirements
|
|
128
|
+
|
|
129
|
+
- Node.js 18+
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "collective-memory-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A persistent, graph-based memory system for AI agents (MCP Server)",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "src/server.js",
|
|
6
7
|
"bin": {
|
|
7
|
-
"collective-memory-mcp": "./
|
|
8
|
-
},
|
|
9
|
-
"npx": {
|
|
10
|
-
"true": true
|
|
8
|
+
"collective-memory-mcp": "./src/server.js"
|
|
11
9
|
},
|
|
12
10
|
"scripts": {
|
|
13
|
-
"
|
|
11
|
+
"start": "node src/server.js",
|
|
12
|
+
"test": "node src/test.js"
|
|
14
13
|
},
|
|
15
14
|
"keywords": [
|
|
16
15
|
"mcp",
|
|
@@ -20,7 +19,8 @@
|
|
|
20
19
|
"knowledge-graph",
|
|
21
20
|
"collective",
|
|
22
21
|
"anthropic",
|
|
23
|
-
"claude"
|
|
22
|
+
"claude",
|
|
23
|
+
"model-context-protocol"
|
|
24
24
|
],
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"repository": {
|
|
@@ -29,11 +29,14 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://github.com/YOUR_USERNAME/collective-memory-mcp#readme",
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=18.0.0"
|
|
33
33
|
},
|
|
34
34
|
"os": [
|
|
35
35
|
"darwin",
|
|
36
36
|
"linux",
|
|
37
37
|
"win32"
|
|
38
|
-
]
|
|
38
|
+
],
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^0.6.0"
|
|
41
|
+
}
|
|
39
42
|
}
|
package/src/models.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core data models for the Collective Memory System.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Valid entity types
|
|
7
|
+
*/
|
|
8
|
+
export const ENTITY_TYPES = ["agent", "task", "structure", "artifact", "session"];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Valid relation types
|
|
12
|
+
*/
|
|
13
|
+
export const RELATION_TYPES = [
|
|
14
|
+
"executed_by", // Task -> Agent
|
|
15
|
+
"created", // Task -> Artifact
|
|
16
|
+
"modified", // Task -> Structure
|
|
17
|
+
"documented", // Task -> Structure
|
|
18
|
+
"depends_on", // Task -> Task
|
|
19
|
+
"part_of", // Task -> Session
|
|
20
|
+
"similar_to", // Task -> Task
|
|
21
|
+
"uses", // Task -> Artifact
|
|
22
|
+
"implements", // Artifact -> Structure
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Entity class representing a node in the knowledge graph
|
|
27
|
+
*/
|
|
28
|
+
export class Entity {
|
|
29
|
+
constructor(data = {}) {
|
|
30
|
+
this.name = data.name || "";
|
|
31
|
+
this.entityType = data.entityType || data.entity_type || "";
|
|
32
|
+
this.observations = data.observations || [];
|
|
33
|
+
this.createdAt = data.createdAt || data.created_at || new Date().toISOString();
|
|
34
|
+
this.metadata = data.metadata || {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Convert entity to plain object
|
|
39
|
+
*/
|
|
40
|
+
toJSON() {
|
|
41
|
+
return {
|
|
42
|
+
name: this.name,
|
|
43
|
+
entityType: this.entityType,
|
|
44
|
+
observations: this.observations,
|
|
45
|
+
createdAt: this.createdAt,
|
|
46
|
+
metadata: this.metadata,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Create entity from plain object
|
|
52
|
+
*/
|
|
53
|
+
static fromJSON(data) {
|
|
54
|
+
return new Entity(data);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Relation class representing a directed edge between entities
|
|
60
|
+
*/
|
|
61
|
+
export class Relation {
|
|
62
|
+
constructor(data = {}) {
|
|
63
|
+
this.from = data.from || data.from_entity || "";
|
|
64
|
+
this.to = data.to || data.to_entity || "";
|
|
65
|
+
this.relationType = data.relationType || data.relation_type || "";
|
|
66
|
+
this.createdAt = data.createdAt || data.created_at || new Date().toISOString();
|
|
67
|
+
this.metadata = data.metadata || {};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Convert relation to plain object
|
|
72
|
+
*/
|
|
73
|
+
toJSON() {
|
|
74
|
+
return {
|
|
75
|
+
from: this.from,
|
|
76
|
+
to: this.to,
|
|
77
|
+
relationType: this.relationType,
|
|
78
|
+
createdAt: this.createdAt,
|
|
79
|
+
metadata: this.metadata,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Create relation from plain object
|
|
85
|
+
*/
|
|
86
|
+
static fromJSON(data) {
|
|
87
|
+
return new Relation(data);
|
|
88
|
+
}
|
|
89
|
+
}
|