@jungjaehoon/mama-server 1.7.4 → 1.7.6

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 (3) hide show
  1. package/README.md +29 -13
  2. package/package.json +2 -3
  3. package/src/server.js +68 -30
package/README.md CHANGED
@@ -131,11 +131,17 @@ Once configured, use MAMA through your MCP client:
131
131
  - **Local-First** - All data stored on your device (~/.claude/mama-memory.db)
132
132
  - **Multilingual** - Supports English, Korean, and other languages
133
133
  - **Shared Database** - One database works across all your MCP clients
134
- - **HTTP Embedding Server** - Shared embedding service for fast hook execution
134
+ - **Optional HTTP Embedding Server** - Legacy/standalone-less embedding HTTP mode (opt-in)
135
135
 
136
136
  ## HTTP Embedding Server
137
137
 
138
- The MCP server includes an HTTP embedding API that keeps the model loaded in memory:
138
+ The MCP server can expose an HTTP embedding API, but this is now opt-in.
139
+
140
+ - Default: `stdio` MCP only (no HTTP startup)
141
+ - Recommended: run `@jungjaehoon/mama-os` for API/UI (`3847`) + embedding/chat (`3849`)
142
+ - Legacy opt-in for MCP HTTP: `MAMA_MCP_START_HTTP_EMBEDDING=true`
143
+
144
+ When enabled, the HTTP embedding API keeps the model loaded in memory:
139
145
 
140
146
  ```
141
147
  ┌─────────────────────────────────────────────────┐
@@ -147,7 +153,7 @@ The MCP server includes an HTTP embedding API that keeps the model loaded in mem
147
153
  │ │ │
148
154
  │ ┌────────────────▼────────────────┐ │
149
155
  │ │ HTTP Embedding Server │ │
150
- │ │ 127.0.0.1:3847 │ │
156
+ │ │ 127.0.0.1:3849 │ │
151
157
  │ │ Model stays loaded in memory │ │
152
158
  │ └─────────────────────────────────┘ │
153
159
  └─────────────────────────────────────────────────┘
@@ -163,17 +169,25 @@ The MCP server includes an HTTP embedding API that keeps the model loaded in mem
163
169
 
164
170
  ### Usage Examples
165
171
 
172
+ Enable legacy MCP-launched HTTP mode when starting MCP server:
173
+
174
+ ```bash
175
+ MAMA_MCP_START_HTTP_EMBEDDING=true npx @jungjaehoon/mama-server
176
+ ```
177
+
178
+ Then query the HTTP endpoints:
179
+
166
180
  ```bash
167
181
  # Check server health
168
- curl http://127.0.0.1:3847/health
182
+ curl http://127.0.0.1:3849/health
169
183
 
170
184
  # Generate embedding
171
- curl -X POST http://127.0.0.1:3847/embed \
185
+ curl -X POST http://127.0.0.1:3849/embed \
172
186
  -H "Content-Type: application/json" \
173
187
  -d '{"text": "How does authentication work?"}'
174
188
 
175
189
  # Batch embeddings
176
- curl -X POST http://127.0.0.1:3847/embed/batch \
190
+ curl -X POST http://127.0.0.1:3849/embed/batch \
177
191
  -H "Content-Type: application/json" \
178
192
  -d '{"texts": ["query 1", "query 2", "query 3"]}'
179
193
  ```
@@ -182,14 +196,14 @@ curl -X POST http://127.0.0.1:3847/embed/batch \
182
196
 
183
197
  - **Fast**: ~50ms embedding requests (vs 2-9 seconds loading model each time)
184
198
  - **Shared**: Any local LLM client can use this service
185
- - **Automatic**: Starts with MCP server, no extra configuration needed
199
+ - **Optional**: Enable only when you explicitly need MCP-launched HTTP mode
186
200
  - **Secure**: localhost only (127.0.0.1), no external access
187
201
 
188
202
  ## Graph Viewer
189
203
 
190
204
  Interactive visualization of your reasoning graph.
191
205
 
192
- **Access:** `http://localhost:3847/viewer`
206
+ **Access:** `http://localhost:3847/viewer` (via Standalone) or `http://localhost:3849/viewer` (legacy MCP HTTP mode)
193
207
 
194
208
  **Features:**
195
209
 
@@ -200,16 +214,18 @@ Interactive visualization of your reasoning graph.
200
214
 
201
215
  ## Environment Variables
202
216
 
203
- | Variable | Default | Description |
204
- | ---------------- | -------------------------- | -------------------------- |
205
- | `MAMA_DB_PATH` | `~/.claude/mama-memory.db` | SQLite database location |
206
- | `MAMA_HTTP_PORT` | `3847` | HTTP embedding server port |
217
+ | Variable | Default | Description |
218
+ | ------------------------------- | -------------------------- | -------------------------------------------- |
219
+ | `MAMA_DB_PATH` | `~/.claude/mama-memory.db` | SQLite database location |
220
+ | `MAMA_EMBEDDING_PORT` | `3849` | Embedding HTTP server port |
221
+ | `MAMA_HTTP_PORT` | `3849` | Backward-compatible alias for embedding port |
222
+ | `MAMA_MCP_START_HTTP_EMBEDDING` | `false` | Start embedding HTTP server from MCP process |
207
223
 
208
224
  ## Technical Details
209
225
 
210
226
  - **Database:** SQLite + sqlite-vec extension
211
227
  - **Embeddings:** Transformers.js (Xenova/multilingual-e5-small, 384-dim)
212
- - **Transport:** stdio-based MCP protocol + HTTP embedding server (port 3847)
228
+ - **Transport:** stdio-based MCP protocol (default) + optional HTTP embedding server (port 3849)
213
229
  - **Storage:** ~/.claude/mama-memory.db (configurable via MAMA_DB_PATH)
214
230
  - **Port File:** ~/.mama-embedding-port (for client discovery)
215
231
  - **Node.js:** >= 18.0.0 required
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jungjaehoon/mama-server",
3
- "version": "1.7.4",
3
+ "version": "1.7.6",
4
4
  "description": "MAMA MCP Server - Memory-Augmented MCP Assistant for Claude Code & Desktop",
5
5
  "main": "src/server.js",
6
6
  "bin": {
@@ -40,8 +40,7 @@
40
40
  "node": ">=18.0.0"
41
41
  },
42
42
  "dependencies": {
43
- "@huggingface/transformers": "^3.0.0",
44
- "@jungjaehoon/mama-core": "^1.0.4",
43
+ "@jungjaehoon/mama-core": "^1.1.2",
45
44
  "@modelcontextprotocol/sdk": "^1.0.1",
46
45
  "better-sqlite3": "^11.0.0",
47
46
  "sqlite-vec": "^0.1.0",
package/src/server.js CHANGED
@@ -160,6 +160,9 @@ function validateEnvironment() {
160
160
  */
161
161
  class MAMAServer {
162
162
  constructor() {
163
+ this.legacyHttpEmbeddingMode = process.env.MAMA_MCP_START_HTTP_EMBEDDING === 'true';
164
+ this.legacyNoticeEmittedInToolResponse = false;
165
+
163
166
  this.server = new Server(
164
167
  {
165
168
  name: 'mama-server',
@@ -175,6 +178,13 @@ class MAMAServer {
175
178
  this.setupHandlers();
176
179
  }
177
180
 
181
+ getLegacyMigrationNotice() {
182
+ return (
183
+ '⚠️ Legacy MCP HTTP embedding mode is enabled via MAMA_MCP_START_HTTP_EMBEDDING=true. ' +
184
+ 'This mode is deprecated. Recommended runtime: `mama start` (API/UI 3847, embedding 3849).'
185
+ );
186
+ }
187
+
178
188
  setupHandlers() {
179
189
  // List available tools - Simplified to 4 core tools (2025-11-25)
180
190
  // Design principle: LLM infers relationships from search results
@@ -184,7 +194,7 @@ class MAMAServer {
184
194
  // 1. SAVE - Unified save for decisions and checkpoints
185
195
  {
186
196
  name: 'save',
187
- description: `🤝 Save a decision or checkpoint to your reasoning graph.
197
+ description: `${this.legacyHttpEmbeddingMode ? `${this.getLegacyMigrationNotice()}\n\n` : ''}🤝 Save a decision or checkpoint to your reasoning graph.
188
198
 
189
199
  ⚡ TRIGGERS - Call this when:
190
200
  • User says: "기억해줘", "remember", "decided", "결정했어"
@@ -423,11 +433,27 @@ Returns: summary (4-section), next_steps (DoD + commands), open_files
423
433
  throw new Error(`Unknown tool: ${name}`);
424
434
  }
425
435
 
436
+ const shouldInjectLegacyNotice =
437
+ this.legacyHttpEmbeddingMode && !this.legacyNoticeEmittedInToolResponse;
438
+
439
+ if (shouldInjectLegacyNotice) {
440
+ this.legacyNoticeEmittedInToolResponse = true;
441
+ }
442
+
426
443
  return {
427
444
  content: [
428
445
  {
429
446
  type: 'text',
430
- text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
447
+ text:
448
+ typeof result === 'string'
449
+ ? result
450
+ : JSON.stringify(
451
+ shouldInjectLegacyNotice
452
+ ? { ...result, migration_notice: this.getLegacyMigrationNotice() }
453
+ : result,
454
+ null,
455
+ 2
456
+ ),
431
457
  },
432
458
  ],
433
459
  };
@@ -653,12 +679,25 @@ Returns: summary (4-section), next_steps (DoD + commands), open_files
653
679
  console.error('[MAMA MCP] Listening on stdio transport');
654
680
  console.error('[MAMA MCP] Ready to accept connections');
655
681
 
656
- // Start HTTP embedding server in background (non-blocking)
657
- // Architecture: Standalone owns the server with chat, MCP reuses if available
658
- const embeddingPort = parseInt(
659
- process.env.MAMA_HTTP_PORT || process.env.MAMA_EMBEDDING_PORT || '3847',
660
- 10
661
- );
682
+ // HTTP embedding server startup is disabled by default for MCP.
683
+ // Architecture: Standalone should own HTTP embedding/chat services.
684
+ // Legacy opt-in: set MAMA_MCP_START_HTTP_EMBEDDING=true.
685
+ const startHttpEmbedding = process.env.MAMA_MCP_START_HTTP_EMBEDDING === 'true';
686
+ const rawEmbeddingPort = process.env.MAMA_EMBEDDING_PORT || process.env.MAMA_HTTP_PORT;
687
+ const parsedEmbeddingPort = parseInt(rawEmbeddingPort || '', 10);
688
+ const embeddingPort =
689
+ Number.isInteger(parsedEmbeddingPort) && parsedEmbeddingPort > 0
690
+ ? parsedEmbeddingPort
691
+ : 3849;
692
+
693
+ if (!startHttpEmbedding) {
694
+ console.error('[MAMA MCP] HTTP embedding server startup skipped (default behavior)');
695
+ console.error('[MAMA MCP] Use Standalone for Graph Viewer/Mobile Chat');
696
+ console.error(
697
+ '[MAMA MCP] To enable legacy MCP-launched HTTP: MAMA_MCP_START_HTTP_EMBEDDING=true'
698
+ );
699
+ return;
700
+ }
662
701
 
663
702
  // Check if Standalone (or another instance) already started the embedding server
664
703
  const serverAlreadyRunning = await isEmbeddingServerRunning(embeddingPort);
@@ -667,29 +706,28 @@ Returns: summary (4-section), next_steps (DoD + commands), open_files
667
706
  console.error(`[MAMA MCP] Embedding server already running on port ${embeddingPort}`);
668
707
  console.error('[MAMA MCP] Using existing server (likely started by Standalone with chat)');
669
708
  console.error(`[MAMA MCP] Graph Viewer: http://localhost:${embeddingPort}/viewer`);
670
- } else {
671
- console.error('[MAMA MCP] Starting HTTP embedding server in background...');
672
- embeddingServer
673
- .startEmbeddingServer(embeddingPort)
674
- .then((httpServer) => {
675
- if (httpServer) {
676
- console.error(`[MAMA MCP] HTTP embedding server running on port ${embeddingPort}`);
677
- console.error(`[MAMA MCP] Graph Viewer: http://localhost:${embeddingPort}/viewer`);
678
- console.error('[MAMA MCP] Note: Chat disabled (start Standalone for full features)');
679
- embeddingServer
680
- .warmModel()
681
- .catch((err) => console.error('[MAMA MCP] Model warmup error:', err.message));
682
- } else {
683
- console.error(
684
- '[MAMA MCP] HTTP embedding server skipped (port unavailable or blocked)'
685
- );
686
- }
687
- })
688
- .catch((err) => {
689
- console.error('[MAMA MCP] HTTP embedding server error:', err.message);
690
- console.error('[MAMA MCP] MCP tools will continue to work without Graph Viewer');
691
- });
709
+ return;
692
710
  }
711
+
712
+ console.error('[MAMA MCP] Starting HTTP embedding server in background (legacy opt-in)...');
713
+ embeddingServer
714
+ .startEmbeddingServer(embeddingPort)
715
+ .then((httpServer) => {
716
+ if (httpServer) {
717
+ console.error(`[MAMA MCP] HTTP embedding server running on port ${embeddingPort}`);
718
+ console.error(`[MAMA MCP] Graph Viewer: http://localhost:${embeddingPort}/viewer`);
719
+ console.error('[MAMA MCP] Note: Chat disabled (start Standalone for full features)');
720
+ embeddingServer
721
+ .warmModel()
722
+ .catch((err) => console.error('[MAMA MCP] Model warmup error:', err.message));
723
+ } else {
724
+ console.error('[MAMA MCP] HTTP embedding server skipped (port unavailable or blocked)');
725
+ }
726
+ })
727
+ .catch((err) => {
728
+ console.error('[MAMA MCP] HTTP embedding server error:', err.message);
729
+ console.error('[MAMA MCP] MCP tools will continue to work without Graph Viewer');
730
+ });
693
731
  } catch (error) {
694
732
  console.error('[MAMA MCP] Failed to start server:', error);
695
733
  process.exit(1);