@mediagraph/mcp 1.0.6 → 1.0.7
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/dist/index.js +41 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2559,7 +2559,10 @@ var uploadTools = {
|
|
|
2559
2559
|
definitions: [
|
|
2560
2560
|
{
|
|
2561
2561
|
name: "upload_file",
|
|
2562
|
-
description: `Upload a file
|
|
2562
|
+
description: `Upload a file to Mediagraph. Supports two modes:
|
|
2563
|
+
1. Local file: Provide file_path for files on the user's local filesystem
|
|
2564
|
+
2. Direct upload: Provide file_data (base64-encoded) with filename for files from other sources
|
|
2565
|
+
|
|
2563
2566
|
This creates a new asset in the user's Mediagraph library.
|
|
2564
2567
|
Supports images, videos, audio, documents, and other media files.
|
|
2565
2568
|
The file will be processed and thumbnails/previews generated automatically.`,
|
|
@@ -2570,12 +2573,20 @@ The file will be processed and thumbnails/previews generated automatically.`,
|
|
|
2570
2573
|
type: "string",
|
|
2571
2574
|
description: "Absolute path to the file on the local filesystem"
|
|
2572
2575
|
},
|
|
2576
|
+
file_data: {
|
|
2577
|
+
type: "string",
|
|
2578
|
+
description: "Base64-encoded file content (use this when file_path is not available)"
|
|
2579
|
+
},
|
|
2580
|
+
filename: {
|
|
2581
|
+
type: "string",
|
|
2582
|
+
description: "Filename with extension (required when using file_data)"
|
|
2583
|
+
},
|
|
2573
2584
|
storage_folder_id: {
|
|
2574
2585
|
type: "number",
|
|
2575
2586
|
description: "Optional: ID of the storage folder to upload into"
|
|
2576
2587
|
}
|
|
2577
2588
|
},
|
|
2578
|
-
required: [
|
|
2589
|
+
required: []
|
|
2579
2590
|
}
|
|
2580
2591
|
},
|
|
2581
2592
|
{
|
|
@@ -2603,22 +2614,39 @@ All files are uploaded in a single upload session.`,
|
|
|
2603
2614
|
handlers: {
|
|
2604
2615
|
async upload_file(args, { client: client2 }) {
|
|
2605
2616
|
const filePath = args.file_path;
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2617
|
+
const fileDataB64 = args.file_data;
|
|
2618
|
+
const providedFilename = args.filename;
|
|
2619
|
+
let fileData;
|
|
2620
|
+
let filename;
|
|
2621
|
+
let fileSize;
|
|
2622
|
+
if (fileDataB64) {
|
|
2623
|
+
if (!providedFilename) {
|
|
2624
|
+
return errorResult("filename is required when using file_data");
|
|
2625
|
+
}
|
|
2626
|
+
fileData = Buffer.from(fileDataB64, "base64");
|
|
2627
|
+
filename = providedFilename;
|
|
2628
|
+
fileSize = fileData.length;
|
|
2629
|
+
} else if (filePath) {
|
|
2630
|
+
let fileStats;
|
|
2631
|
+
try {
|
|
2632
|
+
fileStats = await stat(filePath);
|
|
2633
|
+
} catch {
|
|
2634
|
+
return errorResult(`File not found: ${filePath}`);
|
|
2635
|
+
}
|
|
2636
|
+
if (!fileStats.isFile()) {
|
|
2637
|
+
return errorResult(`Not a file: ${filePath}`);
|
|
2638
|
+
}
|
|
2639
|
+
fileData = await readFile(filePath);
|
|
2640
|
+
filename = basename(filePath);
|
|
2641
|
+
fileSize = fileStats.size;
|
|
2642
|
+
} else {
|
|
2643
|
+
return errorResult("Either file_path or file_data (with filename) is required");
|
|
2614
2644
|
}
|
|
2615
|
-
const fileData = await readFile(filePath);
|
|
2616
|
-
const filename = basename(filePath);
|
|
2617
2645
|
const contentType = getMimeType(filename);
|
|
2618
2646
|
const upload = await client2.createUpload();
|
|
2619
2647
|
const preparedAsset = await client2.prepareAssetUpload(upload.guid, {
|
|
2620
2648
|
filename,
|
|
2621
|
-
file_size:
|
|
2649
|
+
file_size: fileSize,
|
|
2622
2650
|
created_via: "mcp"
|
|
2623
2651
|
});
|
|
2624
2652
|
await client2.uploadToSignedUrl(preparedAsset.signed_upload_url, fileData, contentType);
|