Skip to content

Commit f7e4110

Browse files
committed
Refactor Memory Core MCP tools to use unified 'manage_database' command (#8316)
1 parent 501f5f5 commit f7e4110

4 files changed

Lines changed: 88 additions & 44 deletions

File tree

.github/.sync-metadata.json

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"lastSync": "2026-01-04T15:27:17.761Z",
3-
"releasesLastFetched": "2026-01-04T15:27:17.772Z",
2+
"lastSync": "2026-01-04T16:24:55.877Z",
3+
"releasesLastFetched": "2026-01-04T16:24:55.887Z",
44
"pushFailures": [],
55
"issues": {
66
"3789": {
@@ -14226,6 +14226,48 @@
1422614226
"closedAt": "2026-01-04T15:02:24Z",
1422714227
"updatedAt": "2026-01-04T15:02:24Z",
1422814228
"contentHash": "7f44b80bffd76eb083a2daef9e5d76e871fef1d65ca0f595d42c64b5b8b30e3b"
14229+
},
14230+
"8314": {
14231+
"state": "CLOSED",
14232+
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8314.md",
14233+
"closedAt": "2026-01-04T16:15:26Z",
14234+
"updatedAt": "2026-01-04T16:15:26Z",
14235+
"contentHash": "3af50bfdb761759a91e1da0d9deec8eb7bfe66fc3e4a72502ad654c175f80409"
14236+
},
14237+
"8315": {
14238+
"state": "OPEN",
14239+
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8315.md",
14240+
"closedAt": null,
14241+
"updatedAt": "2026-01-04T16:23:49Z",
14242+
"contentHash": "8243d53b6846eb1e452f908c15777d427c7bdfabd805742598c714c96c10c0db"
14243+
},
14244+
"8316": {
14245+
"state": "OPEN",
14246+
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8316.md",
14247+
"closedAt": null,
14248+
"updatedAt": "2026-01-04T16:24:15Z",
14249+
"contentHash": "30b904b5a054f18c232ebfa2b9400d19ad39063d35a4dd784ab768c94a4db7bf"
14250+
},
14251+
"8317": {
14252+
"state": "OPEN",
14253+
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8317.md",
14254+
"closedAt": null,
14255+
"updatedAt": "2026-01-04T16:24:17Z",
14256+
"contentHash": "79d244e24989a560c302643e50968bc16ce70be97583c3c63f554876a67c90fb"
14257+
},
14258+
"8318": {
14259+
"state": "OPEN",
14260+
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8318.md",
14261+
"closedAt": null,
14262+
"updatedAt": "2026-01-04T16:24:19Z",
14263+
"contentHash": "41ed0fcd9659a8e8f5af5df5be95f1cbaa4f6a48e0e146ec087cb23ae4f62a65"
14264+
},
14265+
"8319": {
14266+
"state": "OPEN",
14267+
"path": "/Users/Shared/github/neomjs/neo/.github/ISSUE/issue-8319.md",
14268+
"closedAt": null,
14269+
"updatedAt": "2026-01-04T16:24:21Z",
14270+
"contentHash": "328b4c7494c87b0e5063869d493398ec4915ac327b1778db0ee2a6d19c949db6"
1422914271
}
1423014272
},
1423114273
"releases": {

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

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -61,63 +61,50 @@ paths:
6161
schema:
6262
$ref: '#/components/schemas/ErrorResponse'
6363

64-
/db/start:
64+
/db/manage:
6565
post:
66-
summary: Start Database
67-
operationId: start_database
66+
summary: Manage Database
67+
operationId: manage_database
6868
description: |
69-
Starts the ChromaDB database instance for the Memory Core as a background process, or connects to an existing one.
69+
Manages the lifecycle (start/stop) of the ChromaDB database instance for the Memory Core.
7070
7171
**Behavior:**
72-
- **Managed:** If no database is running on the configured port, this tool spawns a new process managed by this server. This process will be automatically cleaned up when the agent session ends.
73-
- **External:** If a database is already running (e.g., via `npm run ai:server-memory`), this tool simply confirms the connection. The server acts as a client and will NOT kill the database on exit.
72+
- **Start:**
73+
- **Managed:** If no database is running on the configured port, this tool spawns a new process managed by this server. This process will be automatically cleaned up when the agent session ends.
74+
- **External:** If a database is already running (e.g., via `npm run ai:server-memory`), this tool simply confirms the connection. The server acts as a client and will NOT kill the database on exit.
75+
- **Stop:**
76+
- **Managed:** Stops the process spawned by this server.
77+
- **External:** **No effect.** The server cannot stop a database it did not start.
7478
7579
**Multi-Agent / Swarm Recommendation:**
7680
For workflows involving multiple concurrent agents, it is **highly recommended** to start the database externally using `npm run ai:server-memory` before starting the agents. This prevents unexpected disconnects for other agents when the "owner" agent exits.
7781
7882
**When to Use:**
79-
Use this tool if a `healthcheck` reveals that the database process is not running.
80-
tags: ["Database Lifecycle"]
81-
responses:
82-
'200':
83-
description: The database process was started successfully.
84-
content:
85-
application/json:
86-
schema:
87-
$ref: '#/components/schemas/DatabaseLifecycleResponse'
88-
'500':
89-
description: The database process is already running or failed to start.
90-
content:
91-
application/json:
92-
schema:
93-
$ref: '#/components/schemas/ErrorResponse'
94-
95-
/db/stop:
96-
post:
97-
summary: Stop Database
98-
operationId: stop_database
99-
description: |
100-
Stops the running ChromaDB database instance for the Memory Core.
101-
102-
**Debug / Maintenance Tool:**
103-
This tool is generally **not required** for standard workflows. The server now implements automatic process cleanup (for managed instances) when the session concludes.
104-
105-
**Effect:**
106-
- **Managed:** Stops the process spawned by this server.
107-
- **External:** **No effect.** The server cannot stop a database it did not start.
108-
109-
**When to Use:**
110-
Use this only for debugging, forcing a restart, or freeing up resources in a long-running environment where the agent session itself does not exit.
83+
- Use `action: start` if a `healthcheck` reveals that the database process is not running.
84+
- Use `action: stop` for debugging, forcing a restart, or freeing up resources.
11185
tags: ["Database Lifecycle"]
86+
requestBody:
87+
required: true
88+
content:
89+
application/json:
90+
schema:
91+
type: object
92+
required:
93+
- action
94+
properties:
95+
action:
96+
type: string
97+
enum: [start, stop]
98+
description: The action to perform.
11299
responses:
113100
'200':
114-
description: The database process was stopped successfully.
101+
description: Operation completed successfully.
115102
content:
116103
application/json:
117104
schema:
118105
$ref: '#/components/schemas/DatabaseLifecycleResponse'
119106
'500':
120-
description: The database process is not running or failed to stop.
107+
description: Operation failed.
121108
content:
122109
application/json:
123110
schema:

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ class DatabaseLifecycleService extends Base {
6363
}
6464
}
6565

66+
/**
67+
* Manages the database lifecycle based on the provided action.
68+
* @param {Object} params
69+
* @param {String} params.action - 'start' or 'stop'
70+
* @returns {Promise<Object>}
71+
*/
72+
async manageDatabase({action}) {
73+
if (action === 'start') {
74+
return this.startDatabase();
75+
} else if (action === 'stop') {
76+
return this.stopDatabase();
77+
} else {
78+
throw new Error(`Invalid action: ${action}. Must be 'start' or 'stop'.`);
79+
}
80+
}
81+
6682
/**
6783
* Starts the ChromaDB server as a background process, if not already running.
6884
* @returns {Promise<object>} A promise that resolves with the status.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ const serviceMapping = {
2020
get_session_memories: MemoryService .listMemories .bind(MemoryService),
2121
healthcheck : HealthService .healthcheck .bind(HealthService),
2222
import_database : DatabaseService .importDatabase .bind(DatabaseService),
23+
manage_database : DatabaseLifecycleService.manageDatabase .bind(DatabaseLifecycleService),
2324
query_raw_memories : MemoryService .queryMemories .bind(MemoryService),
2425
query_summaries : SummaryService .querySummaries .bind(SummaryService),
25-
start_database : DatabaseLifecycleService.startDatabase .bind(DatabaseLifecycleService),
26-
stop_database : DatabaseLifecycleService.stopDatabase .bind(DatabaseLifecycleService),
2726
summarize_sessions : SessionService .summarizeSessions .bind(SessionService)
2827
};
2928

0 commit comments

Comments
 (0)