collective-memory-mcp 0.1.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 +51 -0
- package/index.js +127 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Collective Memory MCP - npx Wrapper
|
|
2
|
+
|
|
3
|
+
This package provides an `npx` wrapper for the Collective Memory MCP Server, making it easy to run without manually installing Python dependencies.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx collective-memory-mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
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
|
+
## Claude Desktop Configuration
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"mcpServers": {
|
|
21
|
+
"collective-memory": {
|
|
22
|
+
"command": "npx",
|
|
23
|
+
"args": ["-y", "collective-memory-mcp"],
|
|
24
|
+
"env": {
|
|
25
|
+
"COLLECTIVE_MEMORY_DB_PATH": "/path/to/memory.db"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The `-y` flag suppresses the npx prompt and auto-installs the latest version.
|
|
33
|
+
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
- Node.js 16+
|
|
37
|
+
- Python 3.10+
|
|
38
|
+
|
|
39
|
+
## Manual Python Installation
|
|
40
|
+
|
|
41
|
+
If automatic installation fails, install manually:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install collective-memory-mcp
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Then run directly with Python:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
python -m collective_memory
|
|
51
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Collective Memory MCP Server - npx Wrapper
|
|
5
|
+
*
|
|
6
|
+
* This wrapper spawns the Python MCP server, making it available via npx:
|
|
7
|
+
* npx collective-memory-mcp
|
|
8
|
+
*
|
|
9
|
+
* The Python package will be automatically installed on first run.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { spawn, spawnSync } from 'child_process';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import { dirname, join } from 'path';
|
|
15
|
+
import { existsSync, readFileSync } from 'fs';
|
|
16
|
+
import { homedir } from 'os';
|
|
17
|
+
|
|
18
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
19
|
+
const __dirname = dirname(__filename);
|
|
20
|
+
|
|
21
|
+
// ANSI color codes for better output
|
|
22
|
+
const colors = {
|
|
23
|
+
reset: '\x1b[0m',
|
|
24
|
+
red: '\x1b[31m',
|
|
25
|
+
green: '\x1b[32m',
|
|
26
|
+
yellow: '\x1b[33m',
|
|
27
|
+
blue: '\x1b[34m',
|
|
28
|
+
cyan: '\x1b[36m',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function log(message, color = 'reset') {
|
|
32
|
+
console.error(`${colors[color]}${message}${colors.reset}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function findPython() {
|
|
36
|
+
// Try different Python commands
|
|
37
|
+
const pythonCommands = ['python3', 'python', 'python3.12', 'python3.11', 'python3.10'];
|
|
38
|
+
|
|
39
|
+
for (const cmd of pythonCommands) {
|
|
40
|
+
const result = spawnSync(cmd, ['--version'], { stdio: 'pipe' });
|
|
41
|
+
if (result.status === 0) {
|
|
42
|
+
return cmd;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getDbPath() {
|
|
50
|
+
// Allow override via environment variable
|
|
51
|
+
if (process.env.COLLECTIVE_MEMORY_DB_PATH) {
|
|
52
|
+
return process.env.COLLECTIVE_MEMORY_DB_PATH;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Default to ~/.collective-memory/memory.db
|
|
56
|
+
return join(homedir(), '.collective-memory', 'memory.db');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function main() {
|
|
60
|
+
const pythonCmd = findPython();
|
|
61
|
+
|
|
62
|
+
if (!pythonCmd) {
|
|
63
|
+
log('Error: Python 3.10+ is required but not found.', 'red');
|
|
64
|
+
log('Please install Python from https://python.org', 'yellow');
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Check if collective_memory module is available
|
|
69
|
+
const checkModule = spawnSync(pythonCmd, ['-c', 'import collective_memory'], {
|
|
70
|
+
stdio: 'pipe'
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
if (checkModule.status !== 0) {
|
|
74
|
+
log('Collective Memory MCP Server not found. Installing...', 'yellow');
|
|
75
|
+
log('', 'reset');
|
|
76
|
+
|
|
77
|
+
const installArgs = ['-m', 'pip', 'install', '-U', 'collective-memory-mcp'];
|
|
78
|
+
const install = spawn(pythonCmd, installArgs, {
|
|
79
|
+
stdio: 'inherit'
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
install.on('close', (code) => {
|
|
83
|
+
if (code !== 0) {
|
|
84
|
+
log('', 'reset');
|
|
85
|
+
log('Failed to install collective-memory-mcp Python package.', 'red');
|
|
86
|
+
log('You can install it manually:', 'yellow');
|
|
87
|
+
log(` ${pythonCmd} -m pip install collective-memory-mcp`, 'cyan');
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
log('', 'reset');
|
|
92
|
+
log('Installation complete. Starting server...', 'green');
|
|
93
|
+
startServer(pythonCmd);
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
startServer(pythonCmd);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function startServer(pythonCmd) {
|
|
101
|
+
const dbPath = getDbPath();
|
|
102
|
+
|
|
103
|
+
// Spawn the Python MCP server
|
|
104
|
+
const server = spawn(pythonCmd, ['-m', 'collective_memory'], {
|
|
105
|
+
stdio: 'inherit',
|
|
106
|
+
env: {
|
|
107
|
+
...process.env,
|
|
108
|
+
COLLECTIVE_MEMORY_DB_PATH: dbPath,
|
|
109
|
+
PYTHONUNBUFFERED: '1',
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
server.on('error', (err) => {
|
|
114
|
+
log(`Error starting server: ${err.message}`, 'red');
|
|
115
|
+
process.exit(1);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
server.on('exit', (code) => {
|
|
119
|
+
process.exit(code ?? 0);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Handle signals
|
|
124
|
+
process.on('SIGINT', () => process.exit(0));
|
|
125
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
126
|
+
|
|
127
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "collective-memory-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A persistent, graph-based memory system for AI agents (MCP Server)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"collective-memory-mcp": "./index.js"
|
|
8
|
+
},
|
|
9
|
+
"npx": {
|
|
10
|
+
"true": true
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"postinstall": "python -m pip install collective-memory-mcp || pip3 install collective-memory-mcp || pip install collective-memory-mcp"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"memory",
|
|
18
|
+
"agents",
|
|
19
|
+
"ai",
|
|
20
|
+
"knowledge-graph",
|
|
21
|
+
"collective",
|
|
22
|
+
"anthropic",
|
|
23
|
+
"claude"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/YOUR_USERNAME/collective-memory-mcp.git"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/YOUR_USERNAME/collective-memory-mcp#readme",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=16.0.0"
|
|
33
|
+
},
|
|
34
|
+
"os": [
|
|
35
|
+
"darwin",
|
|
36
|
+
"linux",
|
|
37
|
+
"win32"
|
|
38
|
+
]
|
|
39
|
+
}
|