secondbrainos-mcp-server 1.9.0 → 1.10.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 CHANGED
@@ -171,7 +171,7 @@ Credentials are stored securely at `~/.secondbrainos/credentials.json` (created
171
171
  7. **Slash commands** (0 credits): When a user runs a slash command (e.g. `/secondbrainos:agent_my_agent`), the server returns the full agent/skill definition from cache — no API calls
172
172
  8. **`start_secondbrainos`** (0 credits): Builds a context document from cached agents and workflows — an index of all available slash commands with descriptions, enabling Claude to discover and invoke agents/skills autonomously
173
173
  9. **Tool calls** (billed per call): When Claude calls an MCP tool (e.g. `runPromptChain` with a specific entity/entity_id to fetch prompt instructions, or `searchMyKnowledge`), the server executes the API call via `api.secondbrainos.com` with authentication
174
- 10. **File upload**: If a tool argument contains a local file path (e.g. `addToMyKnowledge` with `file_path`), the server validates the extension, uploads the file to GCS via `generateFileUploadGoogleCloudStorageURL`, and replaces the path with the GCS URI before forwarding the API call
174
+ 10. **File upload**: If a tool argument contains a local file path (e.g. `addToMyKnowledge` with `file_path`), the server validates the extension (`.txt`, `.md`, `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp`, `.pdf`), uploads the file to GCS via `generateFileUploadGoogleCloudStorageURL` with the correct MIME type, and replaces the path with the GCS URI before forwarding the API call
175
175
 
176
176
  ### Credit Cost
177
177
 
package/build/index.js CHANGED
@@ -540,17 +540,19 @@ class SecondBrainOSServer {
540
540
  if (!fs.existsSync(trimmed)) {
541
541
  throw new McpError(ErrorCode.InvalidRequest, `Local file not found: ${trimmed}`);
542
542
  }
543
- const fileContent = fs.readFileSync(trimmed, 'utf-8');
544
- if (!fileContent.trim()) {
543
+ const isText = SecondBrainOSServer.TEXT_EXTENSIONS.has(ext);
544
+ const mimeType = SecondBrainOSServer.MIME_TYPES[ext] || 'application/octet-stream';
545
+ const fileBuffer = fs.readFileSync(trimmed);
546
+ if (fileBuffer.length === 0 || (isText && !fileBuffer.toString('utf-8').trim())) {
545
547
  throw new McpError(ErrorCode.InvalidRequest, `File is empty: ${trimmed}`);
546
548
  }
547
549
  const fileName = path.basename(trimmed);
548
- const fileSize = Buffer.byteLength(fileContent, 'utf-8');
550
+ const fileSize = fileBuffer.length;
549
551
  // Step 1: Get signed upload URL from the GCF
550
552
  const uploadUrlResponse = await axios.post(`${this.baseUrl}${this.generateUploadURLPath}`, {
551
553
  file_name: fileName,
552
554
  file_size: fileSize,
553
- mime_type: 'text/plain'
555
+ mime_type: mimeType
554
556
  }, {
555
557
  headers: {
556
558
  'Authorization': `Bearer ${this.userId}:${this.userSecret}`,
@@ -559,10 +561,12 @@ class SecondBrainOSServer {
559
561
  });
560
562
  const { upload_url, gs_path } = uploadUrlResponse.data;
561
563
  // Step 2: PUT file content directly to GCS via signed URL
562
- await axios.put(upload_url, fileContent, {
564
+ await axios.put(upload_url, fileBuffer, {
563
565
  headers: {
564
- 'Content-Type': 'text/plain'
565
- }
566
+ 'Content-Type': mimeType
567
+ },
568
+ maxContentLength: Infinity,
569
+ maxBodyLength: Infinity
566
570
  });
567
571
  console.error(`Uploaded local file to ${gs_path}`);
568
572
  result[key] = gs_path;
@@ -671,6 +675,30 @@ An agent definition combines:
671
675
  - 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
672
676
  - Always retrieve the latest version from the server rather than caching or saving locally
673
677
 
678
+ ## Notes on Key Tools
679
+
680
+ ### File Uploads (\`generateFileUploadGoogleCloudStorageURL\`)
681
+ - **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.
682
+ - Only \`.txt\` and \`.md\` files are supported. \`https://\` URLs are passed through unchanged; \`http://\` is rejected.
683
+
684
+ ### Discovery Tools (\`runPromptChain\`, \`getAIAgentsSchema\`)
685
+ - Use these to **fetch a specific** workflow, prompt, or agent — always pass \`entity\` + \`entity_id\` (or \`tab_id\`). Never call without these parameters.
686
+ - 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.
687
+ - **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.
688
+
689
+ ### Marketplace Search & Service Requests (\`searchWorkflowMarketPlace\`, \`searchServicesMarketPlace\`, \`searchTabsMarketPlace\`, \`requestNewService\`)
690
+ - 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.
691
+ - If nothing matches, use \`requestNewService\` to formally request a new capability instead of working around the gap.
692
+ - \`requestNewService\` **always requires a \`file_path\`** — write the context to a local \`.md\` or \`.txt\` file before calling it.
693
+
694
+ ### Sub-Agent Testing (\`messageSubAgent\`)
695
+ - Engages the user's **public-facing AI agent** configured at \`secondbrainos.com/dashboard > Agent Settings\`.
696
+ - Primarily used to fine-tune and test the agent: verify behaviour, validate knowledge retrieval, confirm tool availability, and debug tool execution end-to-end.
697
+
698
+ ### User State Tools (\`getUserServices\`, \`getUserCredits\`)
699
+ - \`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.
700
+ - \`getUserCredits\` — returns the user's available SBOS credits.
701
+
674
702
  ## Available Agents
675
703
  ${agentIndex || '_None configured_'}
676
704
 
@@ -695,7 +723,18 @@ ${this.cachedFeatures.length > 0
695
723
  console.error("Second Brain OS MCP server running on stdio");
696
724
  }
697
725
  }
698
- SecondBrainOSServer.ALLOWED_EXTENSIONS = ['.txt', '.md'];
726
+ SecondBrainOSServer.ALLOWED_EXTENSIONS = ['.txt', '.md', '.png', '.jpg', '.jpeg', '.gif', '.webp', '.pdf'];
727
+ SecondBrainOSServer.MIME_TYPES = {
728
+ '.txt': 'text/plain',
729
+ '.md': 'text/markdown',
730
+ '.png': 'image/png',
731
+ '.jpg': 'image/jpeg',
732
+ '.jpeg': 'image/jpeg',
733
+ '.gif': 'image/gif',
734
+ '.webp': 'image/webp',
735
+ '.pdf': 'application/pdf',
736
+ };
737
+ SecondBrainOSServer.TEXT_EXTENSIONS = new Set(['.txt', '.md']);
699
738
  // Function to fetch the schema from the API
700
739
  async function fetchSchema() {
701
740
  const userId = process.env.USER_ID;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secondbrainos-mcp-server",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Second Brain OS MCP Server for Claude Desktop",
5
5
  "type": "module",
6
6
  "main": "build/index.js",