@steinx/memory-mcp-1file 0.9.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.
Files changed (4) hide show
  1. package/README.md +64 -0
  2. package/package.json +41 -0
  3. package/postinstall.js +194 -0
  4. package/run.js +40 -0
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @steinx/memory-mcp-1file
2
+
3
+ MCP memory server with semantic search, code indexing, and knowledge graph for AI agents.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # Run directly (downloads binary automatically)
9
+ npx @steinx/memory-mcp-1file
10
+
11
+ # Or with bun
12
+ bunx @steinx/memory-mcp-1file
13
+ ```
14
+
15
+ If you republish this wrapper from a fork, the release workflow automatically derives the published npm scope and repository metadata from the current GitHub repository. For local testing and non-release installs, keep the checked-in `repository` field in `npm/package.json` accurate so the postinstall hook downloads release assets from your repository, or override it at install time with `MEMORY_MCP_RELEASE_REPO=owner/repo`.
16
+
17
+ ## What is this?
18
+
19
+ `memory-mcp` is a [Model Context Protocol](https://modelcontextprotocol.io/) server that provides AI agents with:
20
+
21
+ - **Semantic memory** — store and search memories with embeddings
22
+ - **Code indexing** — parse and index codebases with tree-sitter
23
+ - **Knowledge graph** — entity extraction and relationship tracking
24
+ - **Temporal awareness** — time-based memory queries
25
+
26
+ ## Configuration
27
+
28
+ Use with Claude Code, Cursor, or any MCP-compatible client:
29
+
30
+ ```json
31
+ {
32
+ "mcpServers": {
33
+ "memory": {
34
+ "command": "npx",
35
+ "args": ["-y", "@steinx/memory-mcp-1file"]
36
+ }
37
+ }
38
+ }
39
+ ```
40
+
41
+ ## CLI Options
42
+
43
+ ```bash
44
+ memory-mcp --help # Show all options
45
+ memory-mcp --data-dir /data # Custom database path
46
+ ```
47
+
48
+ ## Supported Platforms
49
+
50
+ | Platform | Architecture |
51
+ |---|---|
52
+ | Linux | x86_64 (musl), ARM64 (musl) |
53
+ | macOS | x86_64, ARM64 (Apple Silicon) |
54
+ | Windows | x86_64 |
55
+
56
+ ## Links
57
+
58
+ - [GitHub Repository](https://github.com/SteinX/memory-mcp-1file)
59
+ - [Releases](https://github.com/SteinX/memory-mcp-1file/releases)
60
+ - [Architecture](https://github.com/SteinX/memory-mcp-1file/blob/master/ARCHITECTURE.md)
61
+
62
+ ## License
63
+
64
+ MIT
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@steinx/memory-mcp-1file",
3
+ "version": "0.9.0",
4
+ "description": "MCP memory server with semantic search, code indexing, and knowledge graph for AI agents",
5
+ "bin": {
6
+ "memory-mcp": "run.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node postinstall.js"
10
+ },
11
+ "keywords": [
12
+ "mcp",
13
+ "memory",
14
+ "ai",
15
+ "semantic-search",
16
+ "knowledge-graph",
17
+ "code-indexing",
18
+ "model-context-protocol"
19
+ ],
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/SteinX/memory-mcp-1file.git"
23
+ },
24
+ "homepage": "https://github.com/SteinX/memory-mcp-1file#readme",
25
+ "bugs": {
26
+ "url": "https://github.com/SteinX/memory-mcp-1file/issues"
27
+ },
28
+ "license": "MIT",
29
+ "engines": {
30
+ "node": ">=18.0.0"
31
+ },
32
+ "publishConfig": {
33
+ "registry": "https://registry.npmjs.org",
34
+ "access": "public"
35
+ },
36
+ "files": [
37
+ "run.js",
38
+ "postinstall.js",
39
+ "README.md"
40
+ ]
41
+ }
package/postinstall.js ADDED
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * postinstall.js — downloads the pre-compiled memory-mcp binary
5
+ * from GitHub Releases for the current platform.
6
+ *
7
+ * Zero external dependencies — uses only Node.js built-ins.
8
+ */
9
+
10
+ const https = require("https");
11
+ const http = require("http");
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+ const { execSync } = require("child_process");
15
+ const os = require("os");
16
+ const zlib = require("zlib");
17
+
18
+ const BINARY_NAME = "memory-mcp";
19
+
20
+ // Map Node.js platform/arch to Rust target triples
21
+ const PLATFORM_MAP = {
22
+ "linux-x64": "x86_64-unknown-linux-musl",
23
+ "linux-arm64": "aarch64-unknown-linux-musl",
24
+ "darwin-x64": "x86_64-apple-darwin",
25
+ "darwin-arm64": "aarch64-apple-darwin",
26
+ "win32-x64": "x86_64-pc-windows-msvc",
27
+ };
28
+
29
+ function getPlatformKey() {
30
+ return `${process.platform}-${process.arch}`;
31
+ }
32
+
33
+ function getTarget() {
34
+ const key = getPlatformKey();
35
+ const target = PLATFORM_MAP[key];
36
+ if (!target) {
37
+ console.error(
38
+ `Unsupported platform: ${key}\n` +
39
+ `Supported platforms: ${Object.keys(PLATFORM_MAP).join(", ")}`
40
+ );
41
+ process.exit(1);
42
+ }
43
+ return target;
44
+ }
45
+
46
+ function getVersion() {
47
+ const pkg = JSON.parse(
48
+ fs.readFileSync(path.join(__dirname, "package.json"), "utf8")
49
+ );
50
+ return pkg.version;
51
+ }
52
+
53
+ function getRepo() {
54
+ const envRepo = process.env.MEMORY_MCP_RELEASE_REPO?.trim();
55
+ if (envRepo) {
56
+ return envRepo.replace(/^https:\/\/github\.com\//, "").replace(/\.git$/, "");
57
+ }
58
+
59
+ const pkg = JSON.parse(
60
+ fs.readFileSync(path.join(__dirname, "package.json"), "utf8")
61
+ );
62
+ const repository = pkg.repository;
63
+ const repositoryUrl = typeof repository === "string" ? repository : repository?.url;
64
+
65
+ if (typeof repositoryUrl === "string") {
66
+ const normalized = repositoryUrl
67
+ .replace(/^git\+/, "")
68
+ .replace(/^https:\/\/github\.com\//, "")
69
+ .replace(/^git@github\.com:/, "")
70
+ .replace(/\.git$/, "");
71
+
72
+ if (normalized.includes("/")) {
73
+ return normalized;
74
+ }
75
+ }
76
+
77
+ return "SteinX/memory-mcp-1file";
78
+ }
79
+
80
+ function getDownloadUrl(repo, version, target) {
81
+ const ext = target.includes("windows") ? ".zip" : ".tar.gz";
82
+ return `https://github.com/${repo}/releases/download/v${version}/${BINARY_NAME}-${version}-${target}${ext}`;
83
+ }
84
+
85
+ /**
86
+ * Follow redirects (GitHub releases use 302 → S3).
87
+ */
88
+ function download(url) {
89
+ return new Promise((resolve, reject) => {
90
+ const client = url.startsWith("https") ? https : http;
91
+ client
92
+ .get(url, { headers: { "User-Agent": "memory-mcp-npm" } }, (res) => {
93
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
94
+ return download(res.headers.location).then(resolve, reject);
95
+ }
96
+ if (res.statusCode !== 200) {
97
+ return reject(
98
+ new Error(`Download failed: HTTP ${res.statusCode} for ${url}`)
99
+ );
100
+ }
101
+ const chunks = [];
102
+ res.on("data", (chunk) => chunks.push(chunk));
103
+ res.on("end", () => resolve(Buffer.concat(chunks)));
104
+ res.on("error", reject);
105
+ })
106
+ .on("error", reject);
107
+ });
108
+ }
109
+
110
+ /**
111
+ * Extract .tar.gz using Node.js built-in zlib + tar command.
112
+ */
113
+ async function extractTarGz(buffer, destDir) {
114
+ fs.mkdirSync(destDir, { recursive: true });
115
+ const tmpFile = path.join(os.tmpdir(), `memory-mcp-${Date.now()}.tar.gz`);
116
+ fs.writeFileSync(tmpFile, buffer);
117
+ try {
118
+ execSync(`tar -xzf "${tmpFile}" -C "${destDir}"`, { stdio: "pipe" });
119
+ } finally {
120
+ fs.unlinkSync(tmpFile);
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Extract .zip using unzip command (available on Windows via PowerShell).
126
+ */
127
+ async function extractZip(buffer, destDir) {
128
+ fs.mkdirSync(destDir, { recursive: true });
129
+ const tmpFile = path.join(os.tmpdir(), `memory-mcp-${Date.now()}.zip`);
130
+ fs.writeFileSync(tmpFile, buffer);
131
+ try {
132
+ if (process.platform === "win32") {
133
+ execSync(
134
+ `powershell -Command "Expand-Archive -Path '${tmpFile}' -DestinationPath '${destDir}' -Force"`,
135
+ { stdio: "pipe" }
136
+ );
137
+ } else {
138
+ execSync(`unzip -o "${tmpFile}" -d "${destDir}"`, { stdio: "pipe" });
139
+ }
140
+ } finally {
141
+ fs.unlinkSync(tmpFile);
142
+ }
143
+ }
144
+
145
+ async function main() {
146
+ const repo = getRepo();
147
+ const target = getTarget();
148
+ const version = getVersion();
149
+ const url = getDownloadUrl(repo, version, target);
150
+ const binDir = path.join(__dirname, "bin");
151
+ const isWindows = target.includes("windows");
152
+ const binaryPath = path.join(
153
+ binDir,
154
+ isWindows ? `${BINARY_NAME}.exe` : BINARY_NAME
155
+ );
156
+
157
+ // Skip if binary already exists
158
+ if (fs.existsSync(binaryPath)) {
159
+ console.log(`memory-mcp binary already exists at ${binaryPath}`);
160
+ return;
161
+ }
162
+
163
+ console.log(`Downloading memory-mcp v${version} for ${target} from ${repo}...`);
164
+ console.log(` URL: ${url}`);
165
+
166
+ try {
167
+ const buffer = await download(url);
168
+
169
+ if (isWindows) {
170
+ await extractZip(buffer, binDir);
171
+ } else {
172
+ await extractTarGz(buffer, binDir);
173
+ }
174
+
175
+ // Make binary executable on Unix
176
+ if (!isWindows) {
177
+ fs.chmodSync(binaryPath, 0o755);
178
+ }
179
+
180
+ console.log(`✅ memory-mcp installed successfully at ${binaryPath}`);
181
+ } catch (err) {
182
+ console.error(`\n❌ Failed to install memory-mcp binary:`);
183
+ console.error(` ${err.message}`);
184
+ console.error(
185
+ `\nYou can manually download the binary from:`
186
+ );
187
+ console.error(
188
+ ` https://github.com/${repo}/releases/tag/v${version}`
189
+ );
190
+ process.exit(1);
191
+ }
192
+ }
193
+
194
+ main();
package/run.js ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * run.js — entry point for `npx memory-mcp` / `bunx memory-mcp`.
5
+ * Finds and executes the pre-compiled binary, proxying stdio and args.
6
+ */
7
+
8
+ const { spawn } = require("child_process");
9
+ const path = require("path");
10
+ const fs = require("fs");
11
+
12
+ const isWindows = process.platform === "win32";
13
+ const binaryName = isWindows ? "memory-mcp.exe" : "memory-mcp";
14
+ const binaryPath = path.join(__dirname, "bin", binaryName);
15
+
16
+ if (!fs.existsSync(binaryPath)) {
17
+ console.error(
18
+ `❌ memory-mcp binary not found at ${binaryPath}\n` +
19
+ ` Run "node postinstall.js" to download it, or reinstall the package.`
20
+ );
21
+ process.exit(1);
22
+ }
23
+
24
+ const child = spawn(binaryPath, process.argv.slice(2), {
25
+ stdio: "inherit",
26
+ env: process.env,
27
+ });
28
+
29
+ child.on("error", (err) => {
30
+ console.error(`Failed to start memory-mcp: ${err.message}`);
31
+ process.exit(1);
32
+ });
33
+
34
+ child.on("exit", (code, signal) => {
35
+ if (signal) {
36
+ process.kill(process.pid, signal);
37
+ } else {
38
+ process.exit(code ?? 1);
39
+ }
40
+ });