secondbrainos-mcp-server 1.9.1 → 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 +1 -1
- package/build/index.js +23 -8
- package/package.json +1 -1
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
|
|
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
|
|
544
|
-
|
|
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 =
|
|
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:
|
|
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,
|
|
564
|
+
await axios.put(upload_url, fileBuffer, {
|
|
563
565
|
headers: {
|
|
564
|
-
'Content-Type':
|
|
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;
|
|
@@ -719,7 +723,18 @@ ${this.cachedFeatures.length > 0
|
|
|
719
723
|
console.error("Second Brain OS MCP server running on stdio");
|
|
720
724
|
}
|
|
721
725
|
}
|
|
722
|
-
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']);
|
|
723
738
|
// Function to fetch the schema from the API
|
|
724
739
|
async function fetchSchema() {
|
|
725
740
|
const userId = process.env.USER_ID;
|