@aeriondyseti/vector-memory-mcp 0.3.0 → 0.5.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 CHANGED
@@ -57,21 +57,44 @@ A production-ready MCP (Model Context Protocol) server that provides semantic me
57
57
 
58
58
  > **Note:** This server requires Bun to run.
59
59
 
60
- ### Installation
60
+ ### Installation & Configuration
61
61
 
62
+ #### Option 1: Global Install (Recommended)
63
+
64
+ **Install:**
62
65
  ```bash
63
- # Clone the repository
64
- git clone https://github.com/AerionDyseti/vector-memory-mcp.git
65
- cd vector-memory-mcp
66
+ bun install -g @aeriondyseti/vector-memory-mcp
67
+ ```
66
68
 
67
- # Install dependencies
68
- bun install
69
+ > **Note:** The installation automatically downloads ML models (~90MB) and verifies native dependencies. This may take a minute on first install.
70
+
71
+ **Configure Claude Code** - Add to `~/.claude/config.json`:
72
+ ```json
73
+ {
74
+ "mcpServers": {
75
+ "memory": {
76
+ "type": "stdio",
77
+ "command": "bunx",
78
+ "args": [
79
+ "--bun",
80
+ "@aeriondyseti/vector-memory-mcp"
81
+ ],
82
+ "env": {}
83
+ }
84
+ }
85
+ }
69
86
  ```
70
87
 
71
- ### Configure Claude Code
88
+ #### Option 2: Local Development
72
89
 
73
- Add to your `~/.claude/config.json`:
90
+ **Install:**
91
+ ```bash
92
+ git clone https://github.com/AerionDyseti/vector-memory-mcp.git
93
+ cd vector-memory-mcp
94
+ bun install
95
+ ```
74
96
 
97
+ **Configure Claude Code** - Add to `~/.claude/config.json`:
75
98
  ```json
76
99
  {
77
100
  "mcpServers": {
@@ -82,8 +105,17 @@ Add to your `~/.claude/config.json`:
82
105
  }
83
106
  }
84
107
  ```
108
+ *Replace `/absolute/path/to/` with your actual installation path.*
109
+
110
+ ---
111
+
112
+ **What gets installed:**
113
+ - The vector-memory-mcp package and all dependencies
114
+ - Native binaries for ONNX Runtime (~32MB) and image processing (~10MB)
115
+ - ML model files automatically downloaded during installation (~90MB, cached in `~/.cache/huggingface/`)
116
+ - **Total first-time setup:** ~130MB of downloads
85
117
 
86
- Replace `/absolute/path/to/` with your actual installation path.
118
+ > 💡 **Tip:** If you need to re-download models or verify dependencies, run: `vector-memory-mcp warmup`
87
119
 
88
120
  ### Start Using It
89
121
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriondyseti/vector-memory-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "A zero-configuration RAG memory server for MCP clients",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "src",
12
+ "scripts",
12
13
  "README.md",
13
14
  "LICENSE"
14
15
  ],
@@ -25,21 +26,32 @@
25
26
  "start": "bun run src/index.ts",
26
27
  "dev": "bun --watch run src/index.ts",
27
28
  "typecheck": "bunx tsc --noEmit",
28
- "test": "bun test --preload ./tests/preload.ts",
29
+ "test": "bun run scripts/test-runner.ts",
30
+ "test:raw": "bun test --preload ./tests/preload.ts",
29
31
  "test:quick": "bun test",
30
32
  "test:coverage": "bun test --preload ./tests/preload.ts --coverage",
31
- "test:preload": "bun run tests/preload.ts"
33
+ "test:preload": "bun run tests/preload.ts",
34
+ "warmup": "bun run scripts/warmup.ts",
35
+ "postinstall": "bun run scripts/warmup.ts"
32
36
  },
33
- "keywords": ["mcp", "memory", "rag", "embeddings", "lancedb"],
37
+ "keywords": ["mcp", "memory", "rag", "embeddings", "lancedb"],
34
38
  "license": "MIT",
35
39
  "dependencies": {
40
+ "@huggingface/transformers": "^3.8.0",
36
41
  "@lancedb/lancedb": "^0.22.3",
37
42
  "@modelcontextprotocol/sdk": "^1.0.0",
38
- "@huggingface/transformers": "^3.8.0",
39
- "apache-arrow": "^21.1.0"
43
+ "hono": "^4.11.3"
40
44
  },
41
45
  "devDependencies": {
42
46
  "@types/bun": "latest",
43
47
  "typescript": "^5.0.0"
48
+ },
49
+ "trustedDependencies": [
50
+ "onnxruntime-node",
51
+ "protobufjs",
52
+ "sharp"
53
+ ],
54
+ "overrides": {
55
+ "onnxruntime-node": "1.23.2"
44
56
  }
45
57
  }
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Test runner wrapper that handles Bun's post-test crash gracefully.
4
+ *
5
+ * Bun crashes during native module cleanup after tests complete successfully.
6
+ * This wrapper captures the output, verifies tests passed, and exits cleanly.
7
+ */
8
+
9
+ import { spawn } from "bun";
10
+
11
+ const proc = spawn(["bun", "test", "--preload", "./tests/preload.ts"], {
12
+ stdout: "pipe",
13
+ stderr: "pipe",
14
+ env: { ...process.env, FORCE_COLOR: "1" },
15
+ });
16
+
17
+ let stdout = "";
18
+ let stderr = "";
19
+
20
+ const decoder = new TextDecoder();
21
+
22
+ // Stream stdout in real-time
23
+ const stdoutReader = proc.stdout.getReader();
24
+ (async () => {
25
+ while (true) {
26
+ const { done, value } = await stdoutReader.read();
27
+ if (done) break;
28
+ const text = decoder.decode(value);
29
+ stdout += text;
30
+ process.stdout.write(text);
31
+ }
32
+ })();
33
+
34
+ // Stream stderr in real-time
35
+ const stderrReader = proc.stderr.getReader();
36
+ (async () => {
37
+ while (true) {
38
+ const { done, value } = await stderrReader.read();
39
+ if (done) break;
40
+ const text = decoder.decode(value);
41
+ stderr += text;
42
+ process.stderr.write(text);
43
+ }
44
+ })();
45
+
46
+ await proc.exited;
47
+
48
+ // Check if tests actually passed by looking for the summary line
49
+ const output = stdout + stderr;
50
+ const passMatch = output.match(/(\d+) pass/);
51
+ const failMatch = output.match(/(\d+) fail/);
52
+
53
+ const passed = passMatch ? parseInt(passMatch[1], 10) : 0;
54
+ const failed = failMatch ? parseInt(failMatch[1], 10) : 0;
55
+
56
+ // Exit based on test results, not Bun's crash
57
+ if (failed > 0) {
58
+ console.error(`\n❌ ${failed} test(s) failed`);
59
+ process.exit(1);
60
+ } else if (passed > 0) {
61
+ console.log(`\n✅ All ${passed} tests passed (ignoring Bun cleanup crash)`);
62
+ process.exit(0);
63
+ } else {
64
+ console.error("\n⚠️ Could not determine test results");
65
+ process.exit(1);
66
+ }
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * Warmup script to pre-download ML models and verify dependencies
5
+ * This runs during installation to ensure everything is ready to use
6
+ */
7
+
8
+ import { config } from "../src/config/index.js";
9
+ import { EmbeddingsService } from "../src/services/embeddings.service.js";
10
+
11
+ async function warmup(): Promise<void> {
12
+ console.log("🔥 Warming up vector-memory-mcp...");
13
+ console.log();
14
+
15
+ try {
16
+ // Check native dependencies
17
+ console.log("✓ Checking native dependencies...");
18
+ try {
19
+ await import("onnxruntime-node");
20
+ console.log(" ✓ onnxruntime-node loaded");
21
+ } catch (e) {
22
+ console.error(" ✗ onnxruntime-node failed:", (e as Error).message);
23
+ process.exit(1);
24
+ }
25
+
26
+ try {
27
+ await import("sharp");
28
+ console.log(" ✓ sharp loaded");
29
+ } catch (e) {
30
+ console.error(" ✗ sharp failed:", (e as Error).message);
31
+ process.exit(1);
32
+ }
33
+
34
+ console.log();
35
+
36
+ // Initialize embeddings service to download model
37
+ console.log("📥 Downloading ML model (this may take a minute)...");
38
+ console.log(` Model: ${config.embeddingModel}`);
39
+ console.log(` Cache: ~/.cache/huggingface/`);
40
+ console.log();
41
+
42
+ const embeddings = new EmbeddingsService(
43
+ config.embeddingModel,
44
+ config.embeddingDimension
45
+ );
46
+
47
+ // Trigger model download by generating a test embedding
48
+ const startTime = Date.now();
49
+ await embeddings.embed("warmup test");
50
+ const duration = ((Date.now() - startTime) / 1000).toFixed(2);
51
+
52
+ console.log();
53
+ console.log(`✅ Warmup complete! (${duration}s)`);
54
+ console.log();
55
+ console.log("Ready to use! Configure Claude Code and restart to get started.");
56
+ console.log("See: https://github.com/AerionDyseti/vector-memory-mcp#configure-claude-code");
57
+ console.log();
58
+ } catch (error) {
59
+ console.error();
60
+ console.error("❌ Warmup failed:", error);
61
+ console.error();
62
+ console.error("This is not a critical error - the server will download models on first run.");
63
+ console.error("You can try running 'vector-memory-mcp warmup' manually later.");
64
+ process.exit(0); // Exit successfully to not block installation
65
+ }
66
+ }
67
+
68
+ // Only run if this is the main module
69
+ if (import.meta.url === `file://${process.argv[1]}`) {
70
+ warmup();
71
+ }
72
+
73
+ export { warmup };
@@ -5,6 +5,9 @@ export interface Config {
5
5
  dbPath: string;
6
6
  embeddingModel: string;
7
7
  embeddingDimension: number;
8
+ httpPort: number;
9
+ httpHost: string;
10
+ enableHttp: boolean;
8
11
  }
9
12
 
10
13
  const DEFAULT_DB_PATH = join(
@@ -17,12 +20,17 @@ const DEFAULT_DB_PATH = join(
17
20
 
18
21
  const DEFAULT_EMBEDDING_MODEL = "Xenova/all-MiniLM-L6-v2";
19
22
  const DEFAULT_EMBEDDING_DIMENSION = 384;
23
+ const DEFAULT_HTTP_PORT = 3271;
24
+ const DEFAULT_HTTP_HOST = "127.0.0.1";
20
25
 
21
26
  export function loadConfig(): Config {
22
27
  return {
23
28
  dbPath: process.env.VECTOR_MEMORY_DB_PATH ?? DEFAULT_DB_PATH,
24
29
  embeddingModel: process.env.VECTOR_MEMORY_MODEL ?? DEFAULT_EMBEDDING_MODEL,
25
30
  embeddingDimension: DEFAULT_EMBEDDING_DIMENSION,
31
+ httpPort: parseInt(process.env.VECTOR_MEMORY_HTTP_PORT ?? String(DEFAULT_HTTP_PORT), 10),
32
+ httpHost: process.env.VECTOR_MEMORY_HTTP_HOST ?? DEFAULT_HTTP_HOST,
33
+ enableHttp: process.env.VECTOR_MEMORY_ENABLE_HTTP !== "false",
26
34
  };
27
35
  }
28
36
 
@@ -0,0 +1,173 @@
1
+ import { Hono } from "hono";
2
+ import { cors } from "hono/cors";
3
+ import type { MemoryService } from "../services/memory.service.js";
4
+ import type { Config } from "../config/index.js";
5
+ import { isDeleted } from "../types/memory.js";
6
+
7
+ export interface HttpServerOptions {
8
+ memoryService: MemoryService;
9
+ config: Config;
10
+ }
11
+
12
+ export function createHttpApp(memoryService: MemoryService): Hono {
13
+ const app = new Hono();
14
+
15
+ // Enable CORS for local development
16
+ app.use("/*", cors());
17
+
18
+ // Health check endpoint
19
+ app.get("/health", (c) => {
20
+ return c.json({ status: "ok", timestamp: new Date().toISOString() });
21
+ });
22
+
23
+ // Context endpoint for Claude Code hooks
24
+ // Returns relevant memories formatted for injection into conversation
25
+ app.post("/context", async (c) => {
26
+ try {
27
+ const body = await c.req.json();
28
+ const query = body.query;
29
+
30
+ if (!query || typeof query !== "string") {
31
+ return c.json({ error: "Missing or invalid 'query' field" }, 400);
32
+ }
33
+
34
+ const memories = await memoryService.search(query, 5);
35
+
36
+ if (memories.length === 0) {
37
+ return c.json({ context: null });
38
+ }
39
+
40
+ // Format memories for context injection
41
+ const contextLines = memories.map((m, i) => {
42
+ const metadata = m.metadata as Record<string, unknown>;
43
+ const type = metadata.type ? `[${metadata.type}]` : "";
44
+ const date = m.createdAt.toISOString().split("T")[0];
45
+ return `${i + 1}. ${type} (${date}): ${m.content}`;
46
+ });
47
+
48
+ const context = `<relevant-memories>\n${contextLines.join("\n")}\n</relevant-memories>`;
49
+
50
+ return c.json({ context, count: memories.length });
51
+ } catch (error) {
52
+ const message = error instanceof Error ? error.message : "Unknown error";
53
+ return c.json({ error: message }, 500);
54
+ }
55
+ });
56
+
57
+ // Search endpoint (more detailed than /context)
58
+ app.post("/search", async (c) => {
59
+ try {
60
+ const body = await c.req.json();
61
+ const query = body.query;
62
+ const limit = body.limit ?? 10;
63
+
64
+ if (!query || typeof query !== "string") {
65
+ return c.json({ error: "Missing or invalid 'query' field" }, 400);
66
+ }
67
+
68
+ const memories = await memoryService.search(query, limit);
69
+
70
+ return c.json({
71
+ memories: memories.map((m) => ({
72
+ id: m.id,
73
+ content: m.content,
74
+ metadata: m.metadata,
75
+ createdAt: m.createdAt.toISOString(),
76
+ })),
77
+ count: memories.length,
78
+ });
79
+ } catch (error) {
80
+ const message = error instanceof Error ? error.message : "Unknown error";
81
+ return c.json({ error: message }, 500);
82
+ }
83
+ });
84
+
85
+ // Store endpoint
86
+ app.post("/store", async (c) => {
87
+ try {
88
+ const body = await c.req.json();
89
+ const { content, metadata, embeddingText } = body;
90
+
91
+ if (!content || typeof content !== "string") {
92
+ return c.json({ error: "Missing or invalid 'content' field" }, 400);
93
+ }
94
+
95
+ const memory = await memoryService.store(
96
+ content,
97
+ metadata ?? {},
98
+ embeddingText
99
+ );
100
+
101
+ return c.json({
102
+ id: memory.id,
103
+ createdAt: memory.createdAt.toISOString(),
104
+ });
105
+ } catch (error) {
106
+ const message = error instanceof Error ? error.message : "Unknown error";
107
+ return c.json({ error: message }, 500);
108
+ }
109
+ });
110
+
111
+ // Delete endpoint
112
+ app.delete("/memories/:id", async (c) => {
113
+ try {
114
+ const id = c.req.param("id");
115
+ const deleted = await memoryService.delete(id);
116
+
117
+ if (!deleted) {
118
+ return c.json({ error: "Memory not found" }, 404);
119
+ }
120
+
121
+ return c.json({ deleted: true });
122
+ } catch (error) {
123
+ const message = error instanceof Error ? error.message : "Unknown error";
124
+ return c.json({ error: message }, 500);
125
+ }
126
+ });
127
+
128
+ // Get single memory
129
+ app.get("/memories/:id", async (c) => {
130
+ try {
131
+ const id = c.req.param("id");
132
+ const memory = await memoryService.get(id);
133
+
134
+ if (!memory || isDeleted(memory)) {
135
+ return c.json({ error: "Memory not found" }, 404);
136
+ }
137
+
138
+ return c.json({
139
+ id: memory.id,
140
+ content: memory.content,
141
+ metadata: memory.metadata,
142
+ createdAt: memory.createdAt.toISOString(),
143
+ updatedAt: memory.updatedAt.toISOString(),
144
+ });
145
+ } catch (error) {
146
+ const message = error instanceof Error ? error.message : "Unknown error";
147
+ return c.json({ error: message }, 500);
148
+ }
149
+ });
150
+
151
+ return app;
152
+ }
153
+
154
+ export async function startHttpServer(
155
+ memoryService: MemoryService,
156
+ config: Config
157
+ ): Promise<{ stop: () => void }> {
158
+ const app = createHttpApp(memoryService);
159
+
160
+ const server = Bun.serve({
161
+ port: config.httpPort,
162
+ hostname: config.httpHost,
163
+ fetch: app.fetch,
164
+ });
165
+
166
+ console.error(
167
+ `[vector-memory-mcp] HTTP server listening on http://${config.httpHost}:${config.httpPort}`
168
+ );
169
+
170
+ return {
171
+ stop: () => server.stop(),
172
+ };
173
+ }
package/src/index.ts CHANGED
@@ -6,8 +6,17 @@ import { MemoryRepository } from "./db/memory.repository.js";
6
6
  import { EmbeddingsService } from "./services/embeddings.service.js";
7
7
  import { MemoryService } from "./services/memory.service.js";
8
8
  import { startServer } from "./mcp/server.js";
9
+ import { startHttpServer } from "./http/server.js";
9
10
 
10
11
  async function main(): Promise<void> {
12
+ // Check for warmup command
13
+ const args = process.argv.slice(2);
14
+ if (args[0] === "warmup") {
15
+ const { warmup } = await import("../scripts/warmup.js");
16
+ await warmup();
17
+ return;
18
+ }
19
+
11
20
  // Initialize database
12
21
  const db = await connectToDatabase(config.dbPath);
13
22
 
@@ -16,7 +25,12 @@ async function main(): Promise<void> {
16
25
  const embeddings = new EmbeddingsService(config.embeddingModel, config.embeddingDimension);
17
26
  const memoryService = new MemoryService(repository, embeddings);
18
27
 
19
- // Start MCP server
28
+ // Start HTTP server if enabled
29
+ if (config.enableHttp) {
30
+ await startHttpServer(memoryService, config);
31
+ }
32
+
33
+ // Start MCP server (stdio)
20
34
  await startServer(memoryService);
21
35
  }
22
36
 
package/src/mcp/tools.ts CHANGED
@@ -3,7 +3,13 @@ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
3
3
  export const storeMemoryTool: Tool = {
4
4
  name: "store_memory",
5
5
  description:
6
- "Store a new memory. Use this to save information for later recall. " +
6
+ "Store a new memory for later recall. " +
7
+ "PROACTIVELY store memories when: " +
8
+ "(1) Important decisions are made (technical choices, architecture decisions, tradeoffs); " +
9
+ "(2) Problems are solved (bugs fixed, errors resolved - include the solution); " +
10
+ "(3) User preferences or conventions are established; " +
11
+ "(4) Project-specific patterns or configurations are discussed; " +
12
+ "(5) Key information would be valuable in future sessions. " +
7
13
  "IMPORTANT: If the content exceeds 1000 characters, you MUST provide an embedding_text " +
8
14
  "parameter with a concise summary (under 1000 characters) that captures the key semantic " +
9
15
  "meaning for search purposes. The full content will still be stored and returned in search results.",
@@ -12,18 +18,21 @@ export const storeMemoryTool: Tool = {
12
18
  properties: {
13
19
  content: {
14
20
  type: "string",
15
- description: "The text content to store as a memory",
21
+ description:
22
+ "The text content to store. Write in a way that will be useful when retrieved later - " +
23
+ "include context, reasoning, and outcomes, not just bare facts.",
16
24
  },
17
25
  embedding_text: {
18
26
  type: "string",
19
27
  description:
20
28
  "A concise summary (under 1000 characters) used for generating the search embedding. " +
21
- "REQUIRED when content exceeds 1000 characters. If not provided, the full content is used for embedding, " +
22
- "which may be truncated by the embedding model and result in poor search relevance.",
29
+ "REQUIRED when content exceeds 1000 characters. Should capture the key topics and terms " +
30
+ "someone might search for to find this memory.",
23
31
  },
24
32
  metadata: {
25
33
  type: "object",
26
- description: "Optional key-value metadata to attach to the memory",
34
+ description:
35
+ "Optional key-value metadata. Recommended keys: 'project' (project name), 'type' (decision/solution/preference/pattern), 'tags' (array of keywords).",
27
36
  additionalProperties: true,
28
37
  },
29
38
  },
@@ -50,13 +59,22 @@ export const deleteMemoryTool: Tool = {
50
59
  export const searchMemoriesTool: Tool = {
51
60
  name: "search_memories",
52
61
  description:
53
- "Search for memories using semantic similarity. Returns the most relevant memories for the given query.",
62
+ "Search for memories using semantic similarity. Returns the most relevant memories for the given query. " +
63
+ "IMPORTANT: Use this tool PROACTIVELY without being asked when you detect: " +
64
+ "(1) References to past decisions or discussions ('what did we decide', 'as we discussed', 'previously'); " +
65
+ "(2) Questions about prior work ('how did we', 'similar to before', 'like last time'); " +
66
+ "(3) Project continuations or returning to earlier topics; " +
67
+ "(4) Debugging issues that may have been solved before; " +
68
+ "(5) Questions about established patterns, conventions, or preferences. " +
69
+ "When in doubt, search - it's better to check for relevant context than to miss important prior decisions.",
54
70
  inputSchema: {
55
71
  type: "object",
56
72
  properties: {
57
73
  query: {
58
74
  type: "string",
59
- description: "The search query to find relevant memories",
75
+ description:
76
+ "The search query to find relevant memories. Use natural language describing what context you need. " +
77
+ "Include relevant keywords, project names, or technical terms for better results.",
60
78
  },
61
79
  limit: {
62
80
  type: "integer",