Skip to main content
Glama

delete-asset

Remove files from Cloudinary storage by specifying their public or asset ID. This tool helps manage your cloud media library by deleting unwanted assets.

Instructions

Delete a file (asset) from Cloudinary

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
publicIdNoThe public ID of the asset to delete
assetIdNoThe asset ID of the asset to delete

Implementation Reference

  • Core handler function that deletes a Cloudinary asset by publicId (using api.delete_resources) or assetId (using custom DELETE /resources endpoint), handles errors, and returns success/error messages.
    const deleteAssetTool = async (cloudinary, { publicId, assetId }) => {
    	try {
    		let result;
    
    		if (!publicId && !assetId) {
    			throw new Error(`Must provide either publicId or assetId to delete`);
    		}
    
    		if (publicId) {
    			// Delete by public ID using Cloudinary API
    			result = await cloudinary.api.delete_resources(publicId);
    			if (!result || result?.deleted[publicId] === "not_found") {
    				return getToolError(`Failed to delete asset with publicId: '${publicId}' - not_found`, cloudinary);
    			}
    		} else {
    			// Delete by asset ID using /resources endpoint
    			result = await deleteWithAssetId([assetId]);
    
    			if (!result.ok) {
    				return getToolError(`Failed to delete asset with assetId: '${assetId}' - ${result.error.message}`, cloudinary);
    			}
    		}
    
    		return {
    			content: [{
    				type: "text",
    				text: `Successfully deleted asset: '${publicId || assetId}'`
    			}],
    			isError: false,
    		};
    	} catch (error) {
    		return getToolError(`Error deleting asset: ${error.message}`, cloudinary);
    	}
    };
  • Zod schema defining optional publicId or assetId parameters for the delete-asset tool.
    export const deleteAssetToolParams = {
    	publicId: z.string().optional().describe("The public ID of the asset to delete"),
    	assetId: z.string().optional().describe("The asset ID of the asset to delete")
    };
  • src/index.js:47-52 (registration)
    Registers the 'delete-asset' tool on the MCP server with name, description, schema, and wrapped handler.
    server.tool(
    	"delete-asset",
    	"Delete a file (asset) from Cloudinary",
    	deleteAssetToolParams,
    	getDeleteTool(cloudinary),
    );
  • Helper function to delete one or more assets by assetId(s) using direct fetch to Cloudinary's /resources DELETE endpoint.
    const deleteWithAssetId = (assetIds) => {
    	const config = cloudinary.config();
    
    	if (!assetIds || !Array.isArray(assetIds) || assetIds.length === 0) {
    		return Promise.reject(new Error('You must provide an array of asset IDs'));
    	}
    
    	// Format asset_ids[] parameters according to the API requirements
    	const formData = new URLSearchParams();
    	assetIds.forEach(id => formData.append('asset_ids[]', id));
    
    	// Build the request URL
    	const apiUrl = `https://api.cloudinary.com/v1_1/${config.cloud_name}/resources`;
    
    	return fetch(apiUrl, {
    		method: 'DELETE',
    		headers: {
    			'Authorization': `Basic ${Buffer.from(`${config.api_key}:${config.api_secret}`).toString('base64')}`,
    			'Content-Type': 'application/x-www-form-urlencoded'
    		},
    		body: formData.toString()
    	});
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Delete') but fails to add context beyond that, such as whether the deletion is permanent, requires specific permissions, has rate limits, or what the response looks like. This leaves significant gaps for a destructive operation.

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 with zero waste, front-loading the key action and resource. It is appropriately sized for the tool's complexity, making it easy to parse without unnecessary elaboration.

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 destructive nature, lack of annotations, and no output schema, the description is incomplete. It does not address critical aspects like confirmation of deletion, error handling, or return values, leaving the agent with insufficient information for safe and effective use.

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?

The schema description coverage is 100%, with both parameters ('publicId' and 'assetId') documented in the schema. The description does not add any meaning beyond the schema, such as explaining the difference between these IDs or usage scenarios. Baseline 3 is appropriate since the schema handles parameter documentation adequately.

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

Purpose5/5

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

The description clearly states the specific action ('Delete') and resource ('a file (asset) from Cloudinary'), distinguishing it from sibling tools like 'find-assets', 'get-asset', 'get-usage', and 'upload' which perform different operations. It precisely communicates the tool's function without redundancy.

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, such as whether it's for permanent deletion, when to choose 'publicId' vs 'assetId', or if there are prerequisites like authentication. It lacks context on exclusions or comparisons with siblings, offering only the basic purpose.

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