prism-mcp-server 3.1.0 → 3.1.1

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.
@@ -1,6 +1,7 @@
1
1
  import { createClient } from "@libsql/client";
2
- import { resolve } from "path";
2
+ import { resolve, dirname } from "path";
3
3
  import { homedir } from "os";
4
+ import { existsSync, mkdirSync } from "fs";
4
5
  // We use a small, dedicated DB just for configuration settings.
5
6
  // This solves the chicken-and-egg problem: we need to know WHICH
6
7
  // storage backend to boot *before* we can use that backend.
@@ -24,6 +25,13 @@ let initialized = false;
24
25
  let settingsCache = null;
25
26
  function getClient() {
26
27
  if (!configClient) {
28
+ // Ensure the directory exists before opening the DB.
29
+ // In Docker/CI (e.g. Glama), ~/.prism-mcp/ doesn't exist yet,
30
+ // and libSQL throws SQLITE_CANTOPEN (error 14) without it.
31
+ const dir = dirname(CONFIG_PATH);
32
+ if (!existsSync(dir)) {
33
+ mkdirSync(dir, { recursive: true });
34
+ }
27
35
  configClient = createClient({
28
36
  url: `file:${CONFIG_PATH}`,
29
37
  });
@@ -33,19 +41,29 @@ function getClient() {
33
41
  export async function initConfigStorage() {
34
42
  if (initialized)
35
43
  return;
36
- const client = getClient();
37
- await client.execute(`
38
- CREATE TABLE IF NOT EXISTS system_settings (
39
- key TEXT PRIMARY KEY,
40
- value TEXT NOT NULL,
41
- updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
42
- )
43
- `);
44
- // Preload all rows into the cache so subsequent reads are zero-cost.
45
- const rs = await client.execute("SELECT key, value FROM system_settings");
46
- settingsCache = {};
47
- for (const row of rs.rows) {
48
- settingsCache[row.key] = row.value;
44
+ try {
45
+ const client = getClient();
46
+ await client.execute(`
47
+ CREATE TABLE IF NOT EXISTS system_settings (
48
+ key TEXT PRIMARY KEY,
49
+ value TEXT NOT NULL,
50
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
51
+ )
52
+ `);
53
+ // Preload all rows into the cache so subsequent reads are zero-cost.
54
+ const rs = await client.execute("SELECT key, value FROM system_settings");
55
+ settingsCache = {};
56
+ for (const row of rs.rows) {
57
+ settingsCache[row.key] = row.value;
58
+ }
59
+ }
60
+ catch (err) {
61
+ // Graceful degradation: if the DB can't be opened (e.g. read-only
62
+ // filesystem in a sandboxed container), fall back to an empty cache.
63
+ // getSettingSync() will return defaults; getSetting()/setSetting()
64
+ // will attempt to re-open the DB on first call.
65
+ console.error(`[configStorage] Failed to initialize (non-fatal): ${err}`);
66
+ settingsCache = {};
49
67
  }
50
68
  initialized = true;
51
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prism-mcp-server",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "mcpName": "io.github.dcostenco/prism-mcp",
5
5
  "description": "The Mind Palace for AI Agents — local-first MCP server with persistent memory (SQLite/Supabase), visual dashboard, time travel, multi-agent sync, Morning Briefings, reality drift detection, code mode templates, semantic vector search, and Brave Search + Gemini analysis. Zero-config local mode.",
6
6
  "module": "index.ts",