get_notebook_mcp_server 1.1.0 → 1.2.0
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.
- package/index.js +5 -0
- package/package.json +1 -1
- package/src/config/knowledgeBases.js +34 -40
package/index.js
CHANGED
|
@@ -160,6 +160,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
160
160
|
params.topic_ids = [kb.config.topic_id];
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
// Set default value for deep_seek if not provided
|
|
164
|
+
if (params.deep_seek === undefined) {
|
|
165
|
+
params.deep_seek = false;
|
|
166
|
+
}
|
|
167
|
+
|
|
163
168
|
const response = await client.searchKnowledge(params);
|
|
164
169
|
|
|
165
170
|
return {
|
package/package.json
CHANGED
|
@@ -11,54 +11,19 @@ const CONFIG_PATH = path.resolve(__dirname, '../../knowledge_bases.json');
|
|
|
11
11
|
let knowledgeBases = [];
|
|
12
12
|
|
|
13
13
|
export async function loadKnowledgeBases() {
|
|
14
|
-
|
|
15
|
-
const data = await fs.readFile(CONFIG_PATH, 'utf-8');
|
|
16
|
-
knowledgeBases = JSON.parse(data);
|
|
17
|
-
} catch (error) {
|
|
18
|
-
console.warn('Warning: Could not load knowledge_bases.json, using empty list or environment variables.', error.message);
|
|
19
|
-
knowledgeBases = [];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Backward compatibility: Inject KB from environment variables if they exist
|
|
23
|
-
const envApiKey = process.env.GET_API_KEY;
|
|
24
|
-
const envTopicId = process.env.GET_NOTE_TOPIC_ID;
|
|
25
|
-
|
|
26
|
-
if (envApiKey) {
|
|
27
|
-
// Check if already exists to avoid duplicates
|
|
28
|
-
const defaultId = 'default_env_kb';
|
|
29
|
-
const exists = knowledgeBases.find(kb => kb.id === defaultId);
|
|
30
|
-
|
|
31
|
-
if (!exists) {
|
|
32
|
-
knowledgeBases.unshift({
|
|
33
|
-
id: defaultId,
|
|
34
|
-
name: "Default Knowledge Base (Env)",
|
|
35
|
-
description: "Configured via environment variables",
|
|
36
|
-
config: {
|
|
37
|
-
api_endpoint: process.env.GET_API_ENDPOINT || 'https://open-api.biji.com/getnote/openapi',
|
|
38
|
-
api_key: envApiKey,
|
|
39
|
-
topic_id: envTopicId || ''
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Support for multiple KBs via environment variable (JSON string)
|
|
14
|
+
// Priority 1: Load from GET_KNOWLEDGE_BASES environment variable
|
|
46
15
|
const envKbsJson = process.env.GET_KNOWLEDGE_BASES;
|
|
47
16
|
if (envKbsJson) {
|
|
48
17
|
try {
|
|
49
18
|
const envKbs = JSON.parse(envKbsJson);
|
|
50
19
|
if (Array.isArray(envKbs)) {
|
|
51
20
|
const DEFAULT_ENDPOINT = 'https://open-api.biji.com/getnote/openapi';
|
|
52
|
-
// Merge strategies: Append? Prepend? Overwrite?
|
|
53
|
-
// Let's append, but filter out duplicates by ID
|
|
54
21
|
for (const kb of envKbs) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
kb.config.api_endpoint = DEFAULT_ENDPOINT;
|
|
59
|
-
}
|
|
60
|
-
knowledgeBases.push(kb);
|
|
22
|
+
// Apply defaults
|
|
23
|
+
if (kb.config && !kb.config.api_endpoint) {
|
|
24
|
+
kb.config.api_endpoint = DEFAULT_ENDPOINT;
|
|
61
25
|
}
|
|
26
|
+
knowledgeBases.push(kb);
|
|
62
27
|
}
|
|
63
28
|
}
|
|
64
29
|
} catch (e) {
|
|
@@ -66,6 +31,35 @@ export async function loadKnowledgeBases() {
|
|
|
66
31
|
}
|
|
67
32
|
}
|
|
68
33
|
|
|
34
|
+
// Priority 2: Load from knowledge_bases.json file
|
|
35
|
+
if (knowledgeBases.length === 0) {
|
|
36
|
+
try {
|
|
37
|
+
const data = await fs.readFile(CONFIG_PATH, 'utf-8');
|
|
38
|
+
knowledgeBases = JSON.parse(data);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.warn('Warning: Could not load knowledge_bases.json, will try environment variables.', error.message);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Priority 3: Backward compatibility - single KB from GET_API_KEY + GET_NOTE_TOPIC_ID
|
|
45
|
+
if (knowledgeBases.length === 0) {
|
|
46
|
+
const envApiKey = process.env.GET_API_KEY;
|
|
47
|
+
const envTopicId = process.env.GET_NOTE_TOPIC_ID;
|
|
48
|
+
|
|
49
|
+
if (envApiKey) {
|
|
50
|
+
knowledgeBases.push({
|
|
51
|
+
id: 'default_env_kb',
|
|
52
|
+
name: "Default Knowledge Base (Env)",
|
|
53
|
+
description: "Configured via environment variables",
|
|
54
|
+
config: {
|
|
55
|
+
api_endpoint: process.env.GET_API_ENDPOINT || 'https://open-api.biji.com/getnote/openapi',
|
|
56
|
+
api_key: envApiKey,
|
|
57
|
+
topic_id: envTopicId || ''
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
69
63
|
// Expand grouped configurations
|
|
70
64
|
knowledgeBases = expandKnowledgeBases(knowledgeBases);
|
|
71
65
|
|