qa-memorize-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/bin/run.js +53 -0
- package/package.json +23 -0
- package/scripts/postinstall.mjs +36 -0
package/bin/run.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const { spawnSync } = require('child_process');
|
|
7
|
+
const zlib = require('zlib');
|
|
8
|
+
|
|
9
|
+
const PLATFORMS = {
|
|
10
|
+
'win32-x64': { pkg: 'qa-memorize-mcp-win-x64', bin: 'memorize_mcp.exe' },
|
|
11
|
+
'linux-x64': { pkg: 'qa-memorize-mcp-linux-x64', bin: 'memorize_mcp' },
|
|
12
|
+
'darwin-x64': { pkg: 'qa-memorize-mcp-darwin-x64', bin: 'memorize_mcp' },
|
|
13
|
+
'darwin-arm64': { pkg: 'qa-memorize-mcp-darwin-arm64', bin: 'memorize_mcp' },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const key = `${process.platform}-${process.arch}`;
|
|
17
|
+
const entry = PLATFORMS[key];
|
|
18
|
+
if (!entry) {
|
|
19
|
+
console.error('Unsupported platform: ' + key);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let pkgDir;
|
|
24
|
+
try {
|
|
25
|
+
pkgDir = path.dirname(require.resolve(entry.pkg + '/package.json'));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error(`Platform package ${entry.pkg} not found: ${e.message}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const binDir = path.join(pkgDir, 'bin');
|
|
32
|
+
const binPath = path.join(binDir, entry.bin);
|
|
33
|
+
const modelDir = path.join(binDir, 'embedding_model');
|
|
34
|
+
|
|
35
|
+
for (const name of ['model_ort.onnx', 'tokenizer.json']) {
|
|
36
|
+
const dest = path.join(modelDir, name);
|
|
37
|
+
const src = dest + '.gz';
|
|
38
|
+
if (!fs.existsSync(dest) && fs.existsSync(src)) {
|
|
39
|
+
fs.writeFileSync(dest, zlib.gunzipSync(fs.readFileSync(src)));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const args = process.argv.slice(2);
|
|
44
|
+
const finalArgs = args.includes('--model-dir')
|
|
45
|
+
? args
|
|
46
|
+
: ['--model-dir', modelDir, ...args];
|
|
47
|
+
|
|
48
|
+
const result = spawnSync(binPath, finalArgs, {
|
|
49
|
+
stdio: 'inherit',
|
|
50
|
+
env: { ...process.env, ORT_DYLIB_PATH: binDir },
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
process.exit(result.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "qa-memorize-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "RAG-based memory MCP server with local ONNX embeddings",
|
|
5
|
+
"bin": {
|
|
6
|
+
"qa-memorize-mcp": "bin/run.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"postinstall": "node scripts/postinstall.mjs"
|
|
10
|
+
},
|
|
11
|
+
"optionalDependencies": {
|
|
12
|
+
"qa-memorize-mcp-win-x64": "0.1.0",
|
|
13
|
+
"qa-memorize-mcp-linux-x64": "0.1.0",
|
|
14
|
+
"qa-memorize-mcp-darwin-x64": "0.1.0",
|
|
15
|
+
"qa-memorize-mcp-darwin-arm64": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
19
|
+
},
|
|
20
|
+
"keywords": ["mcp", "memorize", "rag", "embedding", "onnx"],
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"author": "whereslow"
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { readFileSync, writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
3
|
+
import { gunzipSync } from 'zlib';
|
|
4
|
+
import { join, dirname } from 'path';
|
|
5
|
+
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
|
|
8
|
+
const platforms = [
|
|
9
|
+
'qa-memorize-mcp-win-x64',
|
|
10
|
+
'qa-memorize-mcp-linux-x64',
|
|
11
|
+
'qa-memorize-mcp-darwin-x64',
|
|
12
|
+
'qa-memorize-mcp-darwin-arm64',
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
let pkgDir = null;
|
|
16
|
+
for (const pkg of platforms) {
|
|
17
|
+
try {
|
|
18
|
+
const pkgJson = require.resolve(`${pkg}/package.json`);
|
|
19
|
+
pkgDir = dirname(pkgJson);
|
|
20
|
+
break;
|
|
21
|
+
} catch {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!pkgDir) process.exit(0);
|
|
25
|
+
|
|
26
|
+
const modelDir = join(pkgDir, 'bin', 'embedding_model');
|
|
27
|
+
|
|
28
|
+
for (const file of ['model_ort.onnx.gz', 'tokenizer.json.gz']) {
|
|
29
|
+
const gz = join(modelDir, file);
|
|
30
|
+
const out = gz.slice(0, -3);
|
|
31
|
+
if (!existsSync(gz)) continue;
|
|
32
|
+
if (existsSync(out)) { unlinkSync(gz); continue; }
|
|
33
|
+
process.stderr.write(`postinstall: decompressing ${file}\n`);
|
|
34
|
+
writeFileSync(out, gunzipSync(readFileSync(gz)));
|
|
35
|
+
unlinkSync(gz);
|
|
36
|
+
}
|