@cybermem/mcp 0.9.12 → 0.13.4

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/Dockerfile CHANGED
@@ -1,39 +1,36 @@
1
- FROM node:18-alpine AS builder
2
-
1
+ # Base stage
2
+ FROM node:20-alpine AS base
3
3
  WORKDIR /app
4
- # Install build dependencies for native modules (better-sqlite3)
5
4
  RUN apk add --no-cache python3 make g++
6
5
 
7
- # Copy package files
6
+ # Build stage
7
+ FROM base AS builder
8
8
  COPY package.json ./
9
- # Install ALL dependencies (including devDeps for build if TS)
10
9
  RUN npm install
11
-
12
- # Copy source
13
10
  COPY . .
14
-
15
- # Build TypeScript
16
11
  RUN npm run build
17
-
18
- # Prune dev dependencies
19
12
  RUN npm prune --production
20
13
 
14
+ # Native stage for sqlite3 bindings
15
+ FROM node:20-alpine AS native-builder
16
+ RUN apk update && apk add --no-cache python3 python3-dev make g++
17
+ WORKDIR /native
18
+ RUN npm init -y && npm install sqlite3@5.1.7 sqlite@5.1.1
21
19
 
20
+ # Runtime stage
22
21
  FROM node:20-alpine AS runner
23
-
24
- WORKDIR /app
25
22
  RUN apk add --no-cache libc6-compat
26
- # Install runtime dependencies for native modules if needed (usually just glibc/musl compatibility, but better-sqlite3 bundles binaries or needs rebuild.
27
- # We copy node_modules from builder so native addons should work if arc matches.
28
- # For cross-platform (building amd64 on arm64 or vice versa), we might need QEMU or specific handling.
29
- # GitHub Actions runner is likely amd64, RPi is arm64.
30
- # We rely on docker buildx (multi-arch) in CI.
23
+ WORKDIR /app
31
24
 
32
25
  # Copy built artifacts and deps
33
26
  COPY --from=builder /app/dist ./dist
34
27
  COPY --from=builder /app/node_modules ./node_modules
35
28
  COPY --from=builder /app/package.json ./package.json
36
29
 
30
+ # Copy compiled native modules (sqlite3 and sqlite)
31
+ COPY --from=native-builder /native/node_modules/sqlite3 ./node_modules/sqlite3
32
+ COPY --from=native-builder /native/node_modules/sqlite ./node_modules/sqlite
33
+
37
34
  # Environment defaults
38
35
  ENV NODE_ENV=production
39
36
  ENV PORT=8080
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // Redirect all stdout to stderr IMMEDIATELY to protect Stdio protocol
4
+ const originalStdoutWrite = process.stdout.write.bind(process.stdout);
5
+ process.stdout.write = (chunk, encoding, callback) => {
6
+ const str = typeof chunk === "string" ? chunk : chunk.toString();
7
+ if (str.includes('"jsonrpc":')) {
8
+ return originalStdoutWrite(chunk, encoding, callback);
9
+ }
10
+ return process.stderr.write(chunk, encoding, callback);
11
+ };
12
+ // Also redirect console outputs
13
+ console.log = console.error;
14
+ console.info = console.error;
package/dist/env.js CHANGED
@@ -3,12 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- /**
7
- * Environment Initialization for CyberMem MCP
8
- * Must be imported first to set side-effect vars.
9
- */
10
6
  const dotenv_1 = __importDefault(require("dotenv"));
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
11
9
  dotenv_1.default.config();
10
+ // CLI Enforcement: Ensure CyberMem is deployed via @cybermem/cli
11
+ if (!process.env.CYBERMEM_INSTANCE) {
12
+ console.error("\n❌ FATAL: CyberMem must be started via @cybermem/cli ('mcp install' or 'mcp up').");
13
+ console.error("Manual 'npm start' or 'docker-compose up' without CLI tagging is forbidden.\n");
14
+ process.exit(1);
15
+ }
16
+ // Normalize OM_DB_PATH early so all components (SDK, exporters) use the same file
17
+ const homedir = os_1.default.homedir();
18
+ process.env.OM_DB_PATH =
19
+ process.env.OM_DB_PATH ||
20
+ path_1.default.resolve(homedir, ".cybermem/data/openmemory.sqlite");
21
+ process.env.DB_PATH = process.env.OM_DB_PATH;
12
22
  process.env.OM_TIER = process.env.OM_TIER || "hybrid";
13
23
  process.env.OM_PORT = process.env.OM_PORT || "0";
14
24
  process.env.PORT = process.env.PORT || "0";