secondbrainos-mcp-server 1.8.2 → 1.9.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/README.md +8 -2
- package/build/index.js +60 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,12 @@ The server exposes four types of MCP prompts, available as slash commands (e.g.
|
|
|
69
69
|
- Each agent appears with an `[Agent]` prefix and returns a structured document containing `agent_id`, `name`, `description`, `behaviour_and_instructions`, `searchMyKnowledge_collection_id`, `actions` (with id, name, description, body_parameters), and `workflows` (with prompt order and description)
|
|
70
70
|
- Supports an optional `user_input` argument
|
|
71
71
|
|
|
72
|
+
#### Features
|
|
73
|
+
- Extracted from the `features` array in the `schema.secondbrainos.com` response at startup, then cached
|
|
74
|
+
- Each feature appears with a `[Feature]` prefix and returns its `guidelines` text
|
|
75
|
+
- Features have consistent guidelines for all users (not user-specific)
|
|
76
|
+
- Supports an optional `user_input` argument
|
|
77
|
+
|
|
72
78
|
#### Knowledge Bases
|
|
73
79
|
- Aggregates all `searchMyKnowledge_collection_id` values from your agents
|
|
74
80
|
- Appears as a single `[Knowledge Bases]` prompt returning an array of collection IDs
|
|
@@ -145,7 +151,7 @@ Credentials are stored securely at `~/.secondbrainos/credentials.json` (created
|
|
|
145
151
|
|
|
146
152
|
### Startup & Session Init
|
|
147
153
|
|
|
148
|
-
1. **Schema Fetching** (0 credits): On startup, the server POSTs your `user_id` to `schema.secondbrainos.com` and receives your personalized OpenAPI spec
|
|
154
|
+
1. **Schema Fetching** (0 credits): On startup, the server POSTs your `user_id` to `schema.secondbrainos.com` and receives your personalized OpenAPI spec along with a `features` array (consistent guidelines for all users)
|
|
149
155
|
2. **Schema Conversion**: The `@samchon/openapi` library converts the spec to LLM function calling format. Each API endpoint becomes an MCP tool. Three service paths are discovered from the spec for internal use:
|
|
150
156
|
- `runPromptChain` — fetches workflows/skills
|
|
151
157
|
- `getAIAgentsSchema` — fetches agents
|
|
@@ -158,7 +164,7 @@ Credentials are stored securely at `~/.secondbrainos/credentials.json` (created
|
|
|
158
164
|
- `runPromptChain` is called with `{}` → returns all user workflows with prompt metadata (name, order, description)
|
|
159
165
|
- `getAIAgentsSchema` is called with `{include_sensitive_config: true}` → returns all user agents with behaviour, knowledge collection ID, actions, and workflows
|
|
160
166
|
5. **In-memory cache**: Both responses are normalized (consistent field names, defaults applied) and sorted (prompts ordered by `order` field), then stored in memory as `cachedWorkflows`, `cachedAgents`, and name-to-ID lookup maps
|
|
161
|
-
6. **Slash commands exposed**: The cached data is surfaced as MCP prompts — `/secondbrainos:skill_*`, `/secondbrainos:agent_*`, `/secondbrainos:start_secondbrainos`, and `/secondbrainos:knowledge_bases`
|
|
167
|
+
6. **Slash commands exposed**: The cached data is surfaced as MCP prompts — `/secondbrainos:feature_*`, `/secondbrainos:skill_*`, `/secondbrainos:agent_*`, `/secondbrainos:start_secondbrainos`, and `/secondbrainos:knowledge_bases`
|
|
162
168
|
|
|
163
169
|
### During the Session
|
|
164
170
|
|
package/build/index.js
CHANGED
|
@@ -15,8 +15,9 @@ function toSnakeCase(str) {
|
|
|
15
15
|
.replace(/^_+|_+$/g, '');
|
|
16
16
|
}
|
|
17
17
|
class SecondBrainOSServer {
|
|
18
|
-
constructor(initialSchema) {
|
|
18
|
+
constructor(initialSchema, features = []) {
|
|
19
19
|
this.originalSpec = initialSchema;
|
|
20
|
+
this.cachedFeatures = features;
|
|
20
21
|
this.baseUrl = process.env.API_BASE_URL || 'https://api.secondbrainos.com';
|
|
21
22
|
this.userId = process.env.USER_ID || '';
|
|
22
23
|
this.userSecret = process.env.USER_SECRET || '';
|
|
@@ -246,6 +247,22 @@ class SecondBrainOSServer {
|
|
|
246
247
|
console.error('Failed to fetch agents for prompts/list:', error);
|
|
247
248
|
}
|
|
248
249
|
}
|
|
250
|
+
// Add feature prompts (from schema response, cached at startup)
|
|
251
|
+
for (const feature of this.cachedFeatures) {
|
|
252
|
+
const snakeName = `feature_${toSnakeCase(feature.name)}`;
|
|
253
|
+
prompts.push({
|
|
254
|
+
name: snakeName,
|
|
255
|
+
title: `[Feature] ${feature.name}`,
|
|
256
|
+
description: feature.guidelines.slice(0, 200) || feature.name,
|
|
257
|
+
arguments: [
|
|
258
|
+
{
|
|
259
|
+
name: "user_input",
|
|
260
|
+
description: "Optional context or input",
|
|
261
|
+
required: false
|
|
262
|
+
}
|
|
263
|
+
]
|
|
264
|
+
});
|
|
265
|
+
}
|
|
249
266
|
// Add start_secondbrainos prompt — returns the server-use context document
|
|
250
267
|
prompts.push({
|
|
251
268
|
name: "start_secondbrainos",
|
|
@@ -333,6 +350,34 @@ class SecondBrainOSServer {
|
|
|
333
350
|
messages
|
|
334
351
|
};
|
|
335
352
|
}
|
|
353
|
+
// Check if this is a feature prompt
|
|
354
|
+
if (promptName.startsWith('feature_')) {
|
|
355
|
+
const feature = this.cachedFeatures.find(f => `feature_${toSnakeCase(f.name)}` === promptName);
|
|
356
|
+
if (feature) {
|
|
357
|
+
const messages = [
|
|
358
|
+
{
|
|
359
|
+
role: "user",
|
|
360
|
+
content: {
|
|
361
|
+
type: "text",
|
|
362
|
+
text: feature.guidelines
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
];
|
|
366
|
+
if (userInput) {
|
|
367
|
+
messages.push({
|
|
368
|
+
role: "user",
|
|
369
|
+
content: {
|
|
370
|
+
type: "text",
|
|
371
|
+
text: userInput
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
description: `Feature: ${feature.name}`,
|
|
377
|
+
messages
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
336
381
|
// Check if this is an agent prompt
|
|
337
382
|
const agentId = this.agentNameToId.get(promptName);
|
|
338
383
|
if (agentId) {
|
|
@@ -631,6 +676,13 @@ ${agentIndex || '_None configured_'}
|
|
|
631
676
|
|
|
632
677
|
## Available Skills
|
|
633
678
|
${skillIndex || '_None configured_'}
|
|
679
|
+
|
|
680
|
+
## Available Features
|
|
681
|
+
${this.cachedFeatures.length > 0
|
|
682
|
+
? this.cachedFeatures
|
|
683
|
+
.map(f => `- ${f.name} → \`/secondbrainos:feature_${toSnakeCase(f.name)}\``)
|
|
684
|
+
.join('\n')
|
|
685
|
+
: '_None configured_'}
|
|
634
686
|
`;
|
|
635
687
|
}
|
|
636
688
|
setupErrorHandling() {
|
|
@@ -653,7 +705,10 @@ async function fetchSchema() {
|
|
|
653
705
|
'Content-Type': 'application/json'
|
|
654
706
|
}
|
|
655
707
|
});
|
|
656
|
-
|
|
708
|
+
const data = response.data;
|
|
709
|
+
// Extract features (if present) and return separately from the OpenAPI spec
|
|
710
|
+
const { features, ...schema } = data;
|
|
711
|
+
return { schema, features: Array.isArray(features) ? features : [] };
|
|
657
712
|
}
|
|
658
713
|
catch (error) {
|
|
659
714
|
console.error('Failed to fetch schema:', error);
|
|
@@ -664,9 +719,9 @@ async function fetchSchema() {
|
|
|
664
719
|
async function main() {
|
|
665
720
|
try {
|
|
666
721
|
// Fetch the schema once at startup
|
|
667
|
-
const schema = await fetchSchema();
|
|
668
|
-
// Initialize the server with the fetched schema
|
|
669
|
-
const server = new SecondBrainOSServer(schema);
|
|
722
|
+
const { schema, features } = await fetchSchema();
|
|
723
|
+
// Initialize the server with the fetched schema and features
|
|
724
|
+
const server = new SecondBrainOSServer(schema, features);
|
|
670
725
|
// Start the server
|
|
671
726
|
await server.run();
|
|
672
727
|
}
|