gaia-vault-mcp
Version:
Azure Blob Storage MCP server for AI assistants
27 lines (26 loc) • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const storage_blob_1 = require("@azure/storage-blob");
const env_1 = require("../config/env");
exports.default = async (containerName, blobName, options) => {
const { connectionString } = (0, env_1.getAzureConfig)();
if (!options.filePath && !options.textContent) {
throw new Error("Either filePath or textContent must be provided");
}
// Create BlobServiceClient
const blobServiceClient = storage_blob_1.BlobServiceClient.fromConnectionString(connectionString);
// Get container client
const containerClient = blobServiceClient.getContainerClient(containerName);
// Create container if it doesn't exist
await containerClient.createIfNotExists();
// Get block blob client
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
// Upload based on the provided option
if (options.filePath) {
await blockBlobClient.uploadFile(options.filePath);
}
else if (options.textContent) {
await blockBlobClient.upload(options.textContent, options.textContent.length);
}
return `Content uploaded successfully. URL: ${blockBlobClient.url}`;
};