secondbrainos-mcp-server 1.8.2 → 1.9.1
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 +84 -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) {
|
|
@@ -626,11 +671,42 @@ An agent definition combines:
|
|
|
626
671
|
- NEVER write these to local disk/drive — even if the user asks. They must always be fetched live from Second Brain OS to avoid stale data
|
|
627
672
|
- Always retrieve the latest version from the server rather than caching or saving locally
|
|
628
673
|
|
|
674
|
+
## Notes on Key Tools
|
|
675
|
+
|
|
676
|
+
### File Uploads (\`generateFileUploadGoogleCloudStorageURL\`)
|
|
677
|
+
- **Almost never call this directly.** The MCP server uses it transparently: when any tool argument named \`file_path\` (or containing \`file_path\`) is a local file path, the server automatically uploads the file to GCS via this service and replaces the path with a \`gs://\` URI before forwarding the call.
|
|
678
|
+
- Only \`.txt\` and \`.md\` files are supported. \`https://\` URLs are passed through unchanged; \`http://\` is rejected.
|
|
679
|
+
|
|
680
|
+
### Discovery Tools (\`runPromptChain\`, \`getAIAgentsSchema\`)
|
|
681
|
+
- Use these to **fetch a specific** workflow, prompt, or agent — always pass \`entity\` + \`entity_id\` (or \`tab_id\`). Never call without these parameters.
|
|
682
|
+
- They can also be used to **list all** workflows / agents, but you shouldn't need to: the start command above already lists everything the server cached at connect time.
|
|
683
|
+
- **If the list returned by these tools differs from what's in this start command**, your MCP connection is stale — ask the user to reconnect/refresh the SBOS MCP server.
|
|
684
|
+
|
|
685
|
+
### Marketplace Search & Service Requests (\`searchWorkflowMarketPlace\`, \`searchServicesMarketPlace\`, \`searchTabsMarketPlace\`, \`requestNewService\`)
|
|
686
|
+
- Users are non-technical. Before suggesting any external step — installing plugins, fetching code from the internet, writing Python/Bash/JavaScript, or exposing webhooks — **first search the marketplaces** for an existing tool, skill, or agent.
|
|
687
|
+
- If nothing matches, use \`requestNewService\` to formally request a new capability instead of working around the gap.
|
|
688
|
+
- \`requestNewService\` **always requires a \`file_path\`** — write the context to a local \`.md\` or \`.txt\` file before calling it.
|
|
689
|
+
|
|
690
|
+
### Sub-Agent Testing (\`messageSubAgent\`)
|
|
691
|
+
- Engages the user's **public-facing AI agent** configured at \`secondbrainos.com/dashboard > Agent Settings\`.
|
|
692
|
+
- Primarily used to fine-tune and test the agent: verify behaviour, validate knowledge retrieval, confirm tool availability, and debug tool execution end-to-end.
|
|
693
|
+
|
|
694
|
+
### User State Tools (\`getUserServices\`, \`getUserCredits\`)
|
|
695
|
+
- \`getUserServices\` — returns services the user currently has access to. If this differs from the MCP tools available in this session, ask the user to reconnect the SBOS MCP server.
|
|
696
|
+
- \`getUserCredits\` — returns the user's available SBOS credits.
|
|
697
|
+
|
|
629
698
|
## Available Agents
|
|
630
699
|
${agentIndex || '_None configured_'}
|
|
631
700
|
|
|
632
701
|
## Available Skills
|
|
633
702
|
${skillIndex || '_None configured_'}
|
|
703
|
+
|
|
704
|
+
## Available Features
|
|
705
|
+
${this.cachedFeatures.length > 0
|
|
706
|
+
? this.cachedFeatures
|
|
707
|
+
.map(f => `- ${f.name} → \`/secondbrainos:feature_${toSnakeCase(f.name)}\``)
|
|
708
|
+
.join('\n')
|
|
709
|
+
: '_None configured_'}
|
|
634
710
|
`;
|
|
635
711
|
}
|
|
636
712
|
setupErrorHandling() {
|
|
@@ -653,7 +729,10 @@ async function fetchSchema() {
|
|
|
653
729
|
'Content-Type': 'application/json'
|
|
654
730
|
}
|
|
655
731
|
});
|
|
656
|
-
|
|
732
|
+
const data = response.data;
|
|
733
|
+
// Extract features (if present) and return separately from the OpenAPI spec
|
|
734
|
+
const { features, ...schema } = data;
|
|
735
|
+
return { schema, features: Array.isArray(features) ? features : [] };
|
|
657
736
|
}
|
|
658
737
|
catch (error) {
|
|
659
738
|
console.error('Failed to fetch schema:', error);
|
|
@@ -664,9 +743,9 @@ async function fetchSchema() {
|
|
|
664
743
|
async function main() {
|
|
665
744
|
try {
|
|
666
745
|
// 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);
|
|
746
|
+
const { schema, features } = await fetchSchema();
|
|
747
|
+
// Initialize the server with the fetched schema and features
|
|
748
|
+
const server = new SecondBrainOSServer(schema, features);
|
|
670
749
|
// Start the server
|
|
671
750
|
await server.run();
|
|
672
751
|
}
|