Skip to content

Commit 41019d1

Browse files
committed
Refactor Memory Core tools: consolidate database backup tools (Issue #8320)
1 parent 9e77ead commit 41019d1

6 files changed

Lines changed: 112 additions & 85 deletions

File tree

.github/.sync-metadata.json

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"lastSync": "2026-01-04T17:16:54.488Z",
3-
"releasesLastFetched": "2026-01-04T17:16:54.935Z",
2+
"lastSync": "2026-01-04T17:50:00.414Z",
3+
"releasesLastFetched": "2026-01-04T17:50:00.937Z",
44
"pushFailures": [],
55
"issues": {
66
"3789": {
@@ -14238,8 +14238,8 @@
1423814238
"state": "OPEN",
1423914239
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8315.md",
1424014240
"closedAt": null,
14241-
"updatedAt": "2026-01-04T16:23:49Z",
14242-
"contentHash": "fad05cae91e25a5f6096a4a7819341ade411bdd4a912441a2ee5037a54f18be7"
14241+
"updatedAt": "2026-01-04T17:18:33Z",
14242+
"contentHash": "0aae9a79e108b73ed596d37c7619c4499b024c263d60e6ec75efa25b2f4a6ecc"
1424314243
},
1424414244
"8316": {
1424514245
"state": "CLOSED",
@@ -14263,11 +14263,18 @@
1426314263
"contentHash": "545b17314ab7a1dfc42f95ea444c16a7d4b76ba576b15b16aef6d036f03685f0"
1426414264
},
1426514265
"8319": {
14266-
"state": "OPEN",
14266+
"state": "CLOSED",
1426714267
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8319.md",
14268+
"closedAt": "2026-01-04T17:45:51Z",
14269+
"updatedAt": "2026-01-04T17:45:51Z",
14270+
"contentHash": "b0d3935311f590d87b70a95f429d715064fca94e8680e3ad14ff9d94ce0f7094"
14271+
},
14272+
"8320": {
14273+
"state": "OPEN",
14274+
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8320.md",
1426814275
"closedAt": null,
14269-
"updatedAt": "2026-01-04T16:24:21Z",
14270-
"contentHash": "328b4c7494c87b0e5063869d493398ec4915ac327b1778db0ee2a6d19c949db6"
14276+
"updatedAt": "2026-01-04T17:49:51Z",
14277+
"contentHash": "b6c20c34da4821f962e8036ff3103e2ae7fe43a508d6abb74ecfb5488a655bd0"
1427114278
}
1427214279
},
1427314280
"releases": {

.github/ISSUE/issue-8315.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ labels:
77
- epic
88
- ai
99
- refactoring
10-
assignees: []
10+
assignees:
11+
- tobiu
1112
createdAt: '2026-01-04T16:23:49Z'
12-
updatedAt: '2026-01-04T16:23:49Z'
13+
updatedAt: '2026-01-04T17:18:33Z'
1314
githubUrl: 'https://github.com/neomjs/neo/issues/8315'
1415
author: tobiu
1516
commentsCount: 0
@@ -18,9 +19,10 @@ subIssues:
1819
- '[x] 8316 MCP: Optimize Memory Core Tool Count'
1920
- '[x] 8317 MCP: Optimize Knowledge Base Tool Count'
2021
- '[x] 8318 MCP: Optimize GitHub Workflow Tool Count'
21-
- '[ ] 8319 MCP: Optimize Neural Link Tool Count'
22-
subIssuesCompleted: 3
23-
subIssuesTotal: 4
22+
- '[x] 8319 MCP: Optimize Neural Link Tool Count'
23+
- '[ ] 8320 MCP: Optimize Memory Core Database Backup Tools'
24+
subIssuesCompleted: 4
25+
subIssuesTotal: 5
2426
blockedBy: []
2527
blocking: []
2628
---
@@ -61,4 +63,7 @@ Reduce the total number of MCP tools by consolidating redundant or complementary
6163
- 2026-01-04 @tobiu added sub-issue #8317
6264
- 2026-01-04 @tobiu added sub-issue #8318
6365
- 2026-01-04 @tobiu added sub-issue #8319
66+
- 2026-01-04 @tobiu assigned to @tobiu
67+
- 2026-01-04 @tobiu cross-referenced by #8320
68+
- 2026-01-04 @tobiu added sub-issue #8320
6469

.github/ISSUE/issue-8319.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
---
22
id: 8319
33
title: 'MCP: Optimize Neural Link Tool Count'
4-
state: OPEN
4+
state: CLOSED
55
labels:
66
- ai
77
- refactoring
8-
assignees: []
8+
assignees:
9+
- tobiu
910
createdAt: '2026-01-04T16:24:21Z'
10-
updatedAt: '2026-01-04T16:24:21Z'
11+
updatedAt: '2026-01-04T17:45:51Z'
1112
githubUrl: 'https://github.com/neomjs/neo/issues/8319'
1213
author: tobiu
13-
commentsCount: 0
14+
commentsCount: 1
1415
parentIssue: 8315
1516
subIssues: []
1617
subIssuesCompleted: 0
1718
subIssuesTotal: 0
1819
blockedBy: []
1920
blocking: []
21+
closedAt: '2026-01-04T17:45:51Z'
2022
---
2123
# MCP: Optimize Neural Link Tool Count
2224

@@ -25,9 +27,31 @@ Part of Epic #8315.
2527
2. Consolidate `get_vdom_tree`, `get_vnode_tree`, and `get_vdom_vnode` into `inspect_component_render_tree` (type: 'vdom' | 'vnode' | 'both').
2628
3. Consolidate `get_neo_config` and `set_neo_config` into `manage_neo_config` (action: 'get' | 'set').
2729

30+
## Comments
31+
32+
### @tobiu - 2026-01-04 17:45
33+
34+
**Input from neo-agent:**
35+
36+
> ◆ I have completed the consolidation of Neural Link tools as requested.
37+
> - `manage_connection` now handles both start and stop actions.
38+
> - `inspect_component_render_tree` consolidates VDOM and VNode inspection.
39+
> - `manage_neo_config` unifies configuration management.
40+
>
41+
> This completes the last sub-task for Epic #8315. All tool consolidation goals have been met.
42+
2843
## Activity Log
2944

3045
- 2026-01-04 @tobiu added the `ai` label
3146
- 2026-01-04 @tobiu added the `refactoring` label
3247
- 2026-01-04 @tobiu added parent issue #8315
48+
- 2026-01-04 @tobiu assigned to @tobiu
49+
- 2026-01-04 @tobiu referenced in commit `9e77ead` - "Refactor Neural Link tools to reduce MCP tool count (Issue #8319)
50+
51+
- Consolidated start/stop_ws_server into manage_connection
52+
53+
- Consolidated get_vdom/vnode_tree into inspect_component_render_tree
54+
55+
- Consolidated get/set_neo_config into manage_neo_config"
56+
- 2026-01-04 @tobiu closed this issue
3357

ai/mcp/server/memory-core/openapi.yaml

Lines changed: 30 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -394,94 +394,69 @@ paths:
394394
schema:
395395
$ref: '#/components/schemas/ErrorResponse'
396396

397-
/db/export:
398-
get:
399-
summary: Export Database
400-
operationId: export_database
401-
x-pass-as-object: true
402-
x-annotations:
403-
readOnlyHint: true
404-
description: |
405-
Exports the entire memory database (both memories and summaries) to a JSONL file.
406-
407-
**When to Use:**
408-
For creating backups or migrating memory data between environments.
409-
tags: [Database]
410-
parameters:
411-
- name: include
412-
in: query
413-
required: false
414-
description: Which collections to export
415-
schema:
416-
type: array
417-
items:
418-
type: string
419-
enum: [memories, summaries]
420-
default: [memories, summaries]
421-
style: form
422-
explode: false
423-
responses:
424-
'200':
425-
description: Database exported successfully
426-
content:
427-
application/x-jsonlines:
428-
schema:
429-
type: string
430-
format: binary
431-
'503':
432-
description: Cannot connect to database
433-
content:
434-
application/json:
435-
schema:
436-
$ref: '#/components/schemas/ErrorResponse'
437-
438-
/db/import:
397+
/db/backup/manage:
439398
post:
440-
summary: Import Database
441-
operationId: import_database
399+
summary: Manage Database Backup
400+
operationId: manage_database_backup
442401
x-pass-as-object: true
443402
description: |
444-
Imports a previously exported JSONL file back into the database.
403+
Manages database backups (import/export).
445404
446405
**When to Use:**
447-
To restore a backup or migrate memory from another environment.
406+
- **Export:** For creating backups or migrating memory data between environments.
407+
- **Import:** To restore a backup or migrate memory from another environment.
448408
tags: [Database]
449409
requestBody:
450410
required: true
451411
content:
452412
multipart/form-data:
453413
schema:
454414
type: object
415+
required:
416+
- action
455417
properties:
418+
action:
419+
type: string
420+
enum: [import, export]
421+
description: The action to perform.
422+
include:
423+
type: array
424+
items:
425+
type: string
426+
enum: [memories, summaries]
427+
default: [memories, summaries]
428+
description: (Export only) Which collections to export.
456429
file:
457430
type: string
458431
format: binary
459-
description: The JSONL backup file to import
432+
description: (Import only) The JSONL backup file to import.
460433
mode:
461434
type: string
462435
enum: [merge, replace]
463436
default: merge
464437
description: |
438+
(Import only) Import mode.
465439
- merge: Add new records, skip existing IDs
466440
- replace: Clear existing data and import
467441
reEmbed:
468442
type: boolean
469443
default: false
470444
description: |
471-
If true, ignores stored embeddings and generates new ones using the current model.
472-
Crucial for model migration (e.g., to gemini-embedding-001).
473-
NOTE: This is a slow operation due to rate limiting (batching).
474-
required:
475-
- file
445+
(Import only) If true, ignores stored embeddings and generates new ones.
476446
responses:
477447
'200':
478-
description: Import completed successfully
448+
description: Operation completed successfully
479449
content:
480450
application/json:
481451
schema:
482-
$ref: '#/components/schemas/ImportResponse'
452+
oneOf:
453+
- $ref: '#/components/schemas/ImportResponse'
454+
- type: object
455+
properties:
456+
message:
457+
type: string
483458
'400':
484-
description: Invalid file or request format
459+
description: Invalid request
485460
content:
486461
application/json:
487462
schema:

ai/mcp/server/memory-core/services/DatabaseService.mjs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class DatabaseService extends Base {
4242
*/
4343
async #exportCollection(collection, backupPath, filePrefix) {
4444
logger.log(`Fetching all documents from "${collection.name}"...`);
45-
45+
4646
// 1. Get total count first
4747
const count = await collection.count();
4848
if (count === 0) {
@@ -60,10 +60,10 @@ class DatabaseService extends Base {
6060
// 2. Paginated Fetch
6161
const limit = 2000; // Safe batch size
6262
let offset = 0;
63-
63+
6464
while (offset < count) {
6565
logger.log(`Fetching batch: ${offset} to ${Math.min(offset + limit, count)} of ${count}`);
66-
66+
6767
const batch = await collection.get({
6868
include: ["documents", "embeddings", "metadatas"],
6969
limit : limit,
@@ -222,6 +222,23 @@ class DatabaseService extends Base {
222222
};
223223
}
224224
}
225+
226+
/**
227+
* Manages database backups (import/export).
228+
* @param {Object} options
229+
* @param {String} options.action The action to perform: 'import' or 'export'.
230+
* @param {Object} [options.config] Additional options for the action.
231+
* @returns {Promise<Object>}
232+
*/
233+
async manageDatabaseBackup({action, ...config}) {
234+
if (action === 'export') {
235+
return this.exportDatabase(config);
236+
} else if (action === 'import') {
237+
return this.importDatabase(config);
238+
} else {
239+
throw new Error(`Unknown action: ${action}`);
240+
}
241+
}
225242
}
226243

227244
export default Neo.setupClass(DatabaseService);

ai/mcp/server/memory-core/services/toolService.mjs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,16 @@ const __dirname = path.dirname(__filename);
1313
const openApiFilePath = path.join(__dirname, '../openapi.yaml');
1414

1515
const serviceMapping = {
16-
add_memory : MemoryService .addMemory .bind(MemoryService),
17-
delete_all_summaries: SummaryService .deleteAllSummaries.bind(SummaryService),
18-
export_database : DatabaseService .exportDatabase .bind(DatabaseService),
19-
get_all_summaries : SummaryService .listSummaries .bind(SummaryService),
20-
get_session_memories: MemoryService .listMemories .bind(MemoryService),
21-
healthcheck : HealthService .healthcheck .bind(HealthService),
22-
import_database : DatabaseService .importDatabase .bind(DatabaseService),
23-
manage_database : DatabaseLifecycleService.manageDatabase .bind(DatabaseLifecycleService),
24-
query_raw_memories : MemoryService .queryMemories .bind(MemoryService),
25-
query_summaries : SummaryService .querySummaries .bind(SummaryService),
26-
summarize_sessions : SessionService .summarizeSessions .bind(SessionService)
16+
add_memory : MemoryService .addMemory .bind(MemoryService),
17+
delete_all_summaries : SummaryService .deleteAllSummaries .bind(SummaryService),
18+
get_all_summaries : SummaryService .listSummaries .bind(SummaryService),
19+
get_session_memories : MemoryService .listMemories .bind(MemoryService),
20+
healthcheck : HealthService .healthcheck .bind(HealthService),
21+
manage_database : DatabaseLifecycleService.manageDatabase .bind(DatabaseLifecycleService),
22+
manage_database_backup: DatabaseService .manageDatabaseBackup.bind(DatabaseService),
23+
query_raw_memories : MemoryService .queryMemories .bind(MemoryService),
24+
query_summaries : SummaryService .querySummaries .bind(SummaryService),
25+
summarize_sessions : SessionService .summarizeSessions .bind(SessionService)
2726
};
2827

2928
const toolService = Neo.create(ToolService, {

0 commit comments

Comments
 (0)