Skip to content

Commit 756c958

Browse files
committed
Refactor MCP Server Configuration #7510
1 parent 2d57001 commit 756c958

7 files changed

Lines changed: 132 additions & 4 deletions

File tree

.github/ISSUE/epic-architect-knowledge-base-as-mcp.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ We will employ a rapid and agile development approach. The scope and API specifi
3636
- `ticket-kb-implement-query-service.md`: Implement the service to query documents from the knowledge base.
3737
- `ticket-kb-implement-sync-service.md`: Implement the service to build and embed the knowledge base content.
3838
- `ticket-kb-implement-document-services.md`: Implement services to list and retrieve individual documents.
39+
40+
### Phase 3: Refactoring & Cleanup
41+
42+
- **Goal:** Improve the modularity and maintainability of the server code.
43+
- **Sub-Tasks:**
44+
- `ticket-kb-refactor-config.md`: Decouple the server from the shared `buildScripts` configuration.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Refactor MCP Server Configuration
3+
labels: enhancement, refactoring, AI
4+
---
5+
6+
Parent epic: #7501
7+
GH ticket id: #7510
8+
9+
**Phase:** 3
10+
**Assignee:** tobiu
11+
**Status:** Done
12+
13+
## Description
14+
15+
This ticket covers the refactoring of the configuration for the MCP servers. Currently, services within the `knowledge-base` server are reaching back into the `buildScripts` directory to import `aiConfig.mjs`.
16+
17+
To improve modularity and prepare for eventual packaging, we will create a centralized configuration file within the `ai/mcp/server/` directory.
18+
19+
## Acceptance Criteria
20+
21+
1. The file `buildScripts/ai/aiConfig.mjs` is copied to `ai/mcp/server/config.mjs`.
22+
2. The new `ai/mcp/server/config.mjs` is modified to remove the `ports` export, which is only relevant to the old Express servers.
23+
3. All service files within `ai/mcp/server/knowledge-base/services/` are updated to import the new config file (`../config.mjs`).
24+
4. The old `buildScripts/ai/aiConfig.mjs` file is left untouched for now, as it is still in use by other scripts.

ai/mcp/server/config.mjs

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import path from 'path';
2+
3+
const aiConfig = {
4+
/**
5+
* A dummy embedding function to satisfy the ChromaDB API when embeddings are provided manually.
6+
* @returns {null}
7+
*/
8+
dummyEmbeddingFunction: {
9+
generate: () => null
10+
},
11+
/**
12+
* Configuration for the AI agent's persistent memory database.
13+
*/
14+
memory: {
15+
/**
16+
* The name of the ChromaDB collection for agent memories.
17+
* @type {string}
18+
*/
19+
collectionName: 'neo-agent-memory',
20+
/**
21+
* The hostname of the ChromaDB server for agent memory.
22+
* @type {string}
23+
*/
24+
host: 'localhost',
25+
/**
26+
* The port the ChromaDB server for agent memory is listening on.
27+
* @type {number}
28+
*/
29+
port: 8001,
30+
/**
31+
* The local persistence path for the agent memory server.
32+
* @type {string}
33+
*/
34+
path: path.resolve(process.cwd(), './chroma-memory'),
35+
/**
36+
* The path to store memory backups.
37+
* @type {string}
38+
*/
39+
backupPath: path.resolve(process.cwd(), 'dist/memory-backups')
40+
},
41+
/**
42+
* Configuration for the AI agent's session summary database.
43+
*/
44+
sessions: {
45+
/**
46+
* The name of the ChromaDB collection for session summaries.
47+
* @type {string}
48+
*/
49+
collectionName: 'neo-agent-sessions',
50+
/**
51+
* The hostname of the ChromaDB server for session summaries.
52+
* @type {string}
53+
*/
54+
host: 'localhost',
55+
/**
56+
* The port the ChromaDB server for session summaries is listening on.
57+
* @type {number}
58+
*/
59+
port: 8001
60+
},
61+
/**
62+
* Configuration for the project's main knowledge base.
63+
*/
64+
knowledgeBase: {
65+
/**
66+
* The path to the generated knowledge base JSONL file.
67+
* @type {string}
68+
*/
69+
path: path.resolve(process.cwd(), 'dist/ai-knowledge-base.jsonl'),
70+
/**
71+
* The name of the ChromaDB collection for the knowledge base.
72+
* @type {string}
73+
*/
74+
collectionName: 'neo_knowledge',
75+
/**
76+
* The name of the Google Generative AI model for text embeddings.
77+
* @type {string}
78+
*/
79+
embeddingModel: 'text-embedding-004',
80+
/**
81+
* The number of chunks to process in a single batch when embedding.
82+
* @type {number}
83+
*/
84+
batchSize: 100,
85+
/**
86+
* The maximum number of times to retry a failed embedding batch.
87+
* @type {number}
88+
*/
89+
maxRetries: 5,
90+
/**
91+
* The number of results to fetch from ChromaDB for a query.
92+
* @type {number}
93+
*/
94+
nResults: 100
95+
}
96+
};
97+
98+
export default aiConfig;

ai/mcp/server/knowledge-base/services/databaseService.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChromaClient } from 'chromadb';
22
import { GoogleGenerativeAI } from '@google/generative-ai';
3-
import aiConfig from '../../../../buildScripts/ai/aiConfig.mjs';
3+
import aiConfig from '../../config.mjs';
44
import crypto from 'crypto';
55
import dotenv from 'dotenv';
66
import fs from 'fs-extra';

ai/mcp/server/knowledge-base/services/documentService.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChromaClient } from 'chromadb';
2-
import aiConfig from '../../../../buildScripts/ai/aiConfig.mjs';
2+
import aiConfig from '../../config.mjs';
33

44
/**
55
* Retrieves a paginated list of all documents from the knowledge base collection.

ai/mcp/server/knowledge-base/services/healthService.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChromaClient } from 'chromadb';
2-
import aiConfig from '../../../../buildScripts/ai/aiConfig.mjs';
2+
import aiConfig from '../../config.mjs';
33

44
/**
55
* Verifies that the server is running and can successfully connect to the

ai/mcp/server/knowledge-base/services/queryService.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ChromaClient } from 'chromadb';
22
import { GoogleGenerativeAI } from '@google/generative-ai';
3-
import aiConfig from '../../../../buildScripts/ai/aiConfig.mjs';
3+
import aiConfig from '../../config.mjs';
44
import dotenv from 'dotenv';
55
import path from 'path';
66

0 commit comments

Comments
 (0)