Skip to main content
Glama

upload

Upload files to Cloudinary from URLs, file paths, or binary data, organizing them with folders, tags, and custom IDs for media management.

Instructions

Upload a file (asset) to Cloudinary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesThe source media to upload (URL, file path, base64 content, or binary data)
folderNoOptional folder path in Cloudinary
publicIdNoOptional public ID for the uploaded asset
resourceTypeNoType of resource to uploadauto
tagsNoA string containing Comma-separated list of tags to assign to the asset

Implementation Reference

  • Core handler function that executes the upload logic to Cloudinary, handling different source types (string URL/path/base64 or Buffer) using uploader.upload or upload_stream.
    const uploadTool = async (cloudinary, { source, folder, publicId, resourceType, tags }) => {
    	try {
    		const uploadOptions = {
    			resource_type: resourceType,
    			folder,
    			public_id: publicId,
    			tags,
    		};
    
    		let uploadResult;
    
    		// Handle different source types
    		if (typeof source === 'string') {
    			uploadResult = await cloudinary.uploader.upload(source, uploadOptions);
    		} else if (Buffer.isBuffer(source)) {
    			// Handle Buffer data
    			uploadResult = await new Promise((resolve, reject) => {
    				const uploadStream = cloudinary.uploader.upload_stream(
    					uploadOptions,
    					(error, result) => {
    						if (error) {
    							return reject(error);
    						}
    						resolve(result);
    					}
    				);
    				uploadStream.end(source);
    			});
    		} else {
    			throw new Error("unknown source type: " + typeof source);
    		}
    
    		return {
    			content: [
    				{
    					type: "text",
    					text: JSON.stringify(uploadResult, null, 2)
    				}
    			],
    			isError: false,
    		};
    	} catch (error) {
    		return getToolError(`Error uploading to Cloudinary: ${error.message}`, cloudinary);
    	}
    }
  • Zod schema defining the input parameters for the upload tool.
    export const uploadToolParams = {
    	source: z.union([
    		z.string().url().describe("URL of the image/video to upload"),
    		z.string().describe("Base64 encoded file content or file path"),
    		z.instanceof(Buffer).describe("Binary data to upload")
    	]).describe("The source media to upload (URL, file path, base64 content, or binary data)"),
    	folder: z.string().optional().describe("Optional folder path in Cloudinary"),
    	publicId: z.string().optional().describe("Optional public ID for the uploaded asset"),
    	resourceType: z.enum(["image", "video", "raw", "auto"]).default("auto").describe("Type of resource to upload"),
    	tags: z.string().optional().describe("A string containing Comma-separated list of tags to assign to the asset"),
    };
  • src/index.js:37-42 (registration)
    MCP server tool registration for the 'upload' tool, providing name, description, input schema, and wrapped handler.
    server.tool(
    	"upload",
    	"Upload a file (asset) to Cloudinary",
    	uploadToolParams,
    	getUploadTool(cloudinary),
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal insight. It states the tool uploads a file but doesn't cover critical traits like authentication requirements, rate limits, error handling, or what happens on success (e.g., returns a URL or ID). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. Every word earns its place by clearly conveying the tool's function, making it highly concise and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation operation with 5 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't address behavioral aspects like side effects, return values, or error conditions, leaving the agent with insufficient context to use the tool effectively beyond basic purpose.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description adds no parameter-specific information beyond implying 'source' is required, which is already clear from the schema. This meets the baseline of 3, as the description doesn't compensate but the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('upload') and resource ('a file (asset) to Cloudinary'), making the purpose immediately understandable. It distinguishes from siblings like delete-asset or find-assets by focusing on creation rather than deletion or retrieval. However, it doesn't explicitly contrast with get-asset or get-usage, which keeps it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication needs), when not to use it (e.g., for updates vs. initial uploads), or how it differs from sibling tools like find-assets for locating existing files. This lack of contextual direction leaves the agent to infer usage scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yoavniran/cloudinary-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server