secondbrainos-mcp-server 1.2.2 → 1.2.3
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/build/index.js +58 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -248,12 +248,70 @@ class SecondBrainOSServer {
|
|
|
248
248
|
console.error('Failed to fetch agents for prompts/list:', error);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
+
// Add Knowledge Bases prompt (collects searchMyKnowledge_collection_ids from agents)
|
|
252
|
+
if (this.getAIAgentsSchemaPath) {
|
|
253
|
+
try {
|
|
254
|
+
const agents = await this.fetchAndEnrichAgents();
|
|
255
|
+
const collectionIds = agents
|
|
256
|
+
.map((a) => a.searchMyKnowledge_collection_id)
|
|
257
|
+
.filter((id) => id && id.length > 0);
|
|
258
|
+
if (collectionIds.length > 0) {
|
|
259
|
+
prompts.push({
|
|
260
|
+
name: "Knowledge Bases",
|
|
261
|
+
title: "[Knowledge Bases]",
|
|
262
|
+
description: "Knowledge base collection IDs available to agents",
|
|
263
|
+
arguments: [
|
|
264
|
+
{
|
|
265
|
+
name: "user_input",
|
|
266
|
+
description: "Optional context or input",
|
|
267
|
+
required: false
|
|
268
|
+
}
|
|
269
|
+
]
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
console.error('Failed to build knowledge bases prompt:', error);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
251
277
|
return { prompts };
|
|
252
278
|
});
|
|
253
279
|
// Get a specific prompt (workflow prompt chain or agent document)
|
|
254
280
|
this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
255
281
|
const promptName = request.params.name;
|
|
256
282
|
const userInput = request.params.arguments?.user_input;
|
|
283
|
+
// Check if this is the Knowledge Bases prompt
|
|
284
|
+
if (promptName === "Knowledge Bases") {
|
|
285
|
+
const agents = await this.fetchAndEnrichAgents();
|
|
286
|
+
const collectionIds = agents
|
|
287
|
+
.map((a) => a.searchMyKnowledge_collection_id)
|
|
288
|
+
.filter((id) => id && id.length > 0);
|
|
289
|
+
const knowledgeBasesDocument = {
|
|
290
|
+
searchMyKnowledge_collection_ids: collectionIds
|
|
291
|
+
};
|
|
292
|
+
const messages = [
|
|
293
|
+
{
|
|
294
|
+
role: "user",
|
|
295
|
+
content: {
|
|
296
|
+
type: "text",
|
|
297
|
+
text: JSON.stringify(knowledgeBasesDocument, null, 2)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
];
|
|
301
|
+
if (userInput) {
|
|
302
|
+
messages.push({
|
|
303
|
+
role: "user",
|
|
304
|
+
content: {
|
|
305
|
+
type: "text",
|
|
306
|
+
text: userInput
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
return {
|
|
311
|
+
description: `Knowledge Bases (${collectionIds.length} collection${collectionIds.length !== 1 ? 's' : ''})`,
|
|
312
|
+
messages
|
|
313
|
+
};
|
|
314
|
+
}
|
|
257
315
|
// Check if this is an agent prompt
|
|
258
316
|
const agentId = this.agentNameToId.get(promptName);
|
|
259
317
|
if (agentId) {
|