Skip to content

Commit 4d2db48

Browse files
committed
Enhance Memory Core Health Check #7525
1 parent e266084 commit 4d2db48

3 files changed

Lines changed: 95 additions & 22 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: "Enhance Memory Core Health Check"
3+
labels: enhancement, AI
4+
---
5+
6+
Parent epic: #7520
7+
GH ticket id: #7525
8+
9+
**Phase:** 2
10+
**Assignee:** tobiu
11+
**Status:** Done
12+
13+
## Description
14+
15+
This ticket is to improve the `healthcheck` tool for the `memory-core` server to match the more comprehensive implementation of the `knowledge-base` server. This involves updating the `healthService.mjs` to check for the existence and status of both the `memories` and `summaries` collections, and updating the `openapi.yaml` to reflect the richer response schema.
16+
17+
## Acceptance Criteria
18+
19+
1. The `buildHealthResponse` function in `ai/mcp/server/memory-core/services/healthService.mjs` is updated.
20+
2. The health check now verifies the existence and document count of both the `memories` and `summaries` collections.
21+
3. The `HealthCheckResponse` schema in `ai/mcp/server/memory-core/openapi.yaml` is updated to include the detailed database and collection status, matching the structure of the knowledge-base server's schema.
22+
4. A successful health check call returns the new, richer status object.

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,11 +452,29 @@ components:
452452
type: object
453453
properties:
454454
memories:
455-
type: string
456-
example: "neo-agent-memory"
455+
type: object
456+
properties:
457+
name:
458+
type: string
459+
example: "neo-agent-memory"
460+
exists:
461+
type: boolean
462+
example: true
463+
count:
464+
type: integer
465+
example: 1234
457466
summaries:
458-
type: string
459-
example: "neo-agent-sessions"
467+
type: object
468+
properties:
469+
name:
470+
type: string
471+
example: "neo-agent-sessions"
472+
exists:
473+
type: boolean
474+
example: true
475+
count:
476+
type: integer
477+
example: 56
460478
version:
461479
type: string
462480
example: "1.0.0"
Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,58 @@
1-
import aiConfig from '../../../../../buildScripts/ai/aiConfig.mjs';
21
import chromaManager from './chromaManager.mjs';
32

43
/**
5-
* Builds the payload returned by GET /healthcheck.
6-
* @returns {Promise<Object>}
4+
* Verifies that the server is running and can successfully connect to the
5+
* ChromaDB vector database, including checking for collection existence and counts.
6+
* @returns {Promise<object>} A promise that resolves to the health check status object.
77
*/
88
export async function buildHealthResponse() {
9-
const {heartbeat, memoryCollection, summaryCollection} = await chromaManager.checkConnectivity();
9+
try {
10+
await chromaManager.client.heartbeat();
1011

11-
return {
12-
status : 'healthy',
13-
timestamp: new Date().toISOString(),
14-
database : {
15-
host : aiConfig.memory.host,
16-
port : aiConfig.memory.port,
17-
heartbeat,
18-
collections: {
19-
memories : memoryCollection,
20-
summaries: summaryCollection
12+
let memoryCollection, summaryCollection;
13+
let memoryCount = 0, summaryCount = 0;
14+
15+
try {
16+
memoryCollection = await chromaManager.getMemoryCollection();
17+
memoryCount = await memoryCollection.count();
18+
} catch (e) {
19+
// Collection does not exist, which is a valid state.
20+
}
21+
22+
try {
23+
summaryCollection = await chromaManager.getSummaryCollection();
24+
summaryCount = await summaryCollection.count();
25+
} catch (e) {
26+
// Collection does not exist.
27+
}
28+
29+
return {
30+
status: "healthy",
31+
database: {
32+
connected: true,
33+
collections: {
34+
memories: {
35+
name: aiConfig.memory.collectionName,
36+
exists: !!memoryCollection,
37+
count: memoryCount
38+
},
39+
summaries: {
40+
name: aiConfig.sessions.collectionName,
41+
exists: !!summaryCollection,
42+
count: summaryCount
43+
}
44+
}
45+
},
46+
version: "1.0.0", // TODO: Should come from package.json
47+
uptime: process.uptime()
48+
};
49+
} catch (error) {
50+
return {
51+
status: "unhealthy",
52+
database: {
53+
connected: false,
54+
error: error.message
2155
}
22-
},
23-
uptime: process.uptime()
24-
};
25-
}
56+
};
57+
}
58+
}

0 commit comments

Comments
 (0)