Skip to main content
Glama

get-asset

Retrieve detailed information about a specific file (asset) in Cloudinary, including metadata, tags, and contextual data, by specifying its asset ID, public ID, and resource type.

Instructions

Get the details of a specific file (asset)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assetIdNoThe Cloudinary asset ID
contextNoWhether to include contextual metadata. Default: false
metadataNoWhether to include structured metadata. Default: false
publicIdNoThe public ID of the asset
resourceTypeNoType of asset. Default: image
tagsNoWhether to include the list of tag names. Default: false
typeNoDelivery type. Default: upload

Implementation Reference

  • Core handler function `getAssetTool` that fetches and returns Cloudinary asset details using the provided assetId or publicId, with optional parameters for resource type, delivery type, tags, context, and metadata. Handles errors gracefully.
    const getAssetTool = async (cloudinary, params) => { if (!params.assetId && !params.publicId) { return getToolError("Error: Either assetId or publicId must be provided", cloudinary); } try { const { assetId, publicId, tags, context, metadata, resourceType, type } = params; let resource; if (publicId) { resource = await cloudinary.api.resource(publicId, { resource_type: resourceType, type: type, tags, context, metadata, }); } else { const result = await cloudinary.api .resources_by_asset_ids([assetId], { tags, context, metadata, }); resource = result.resources[0] || null; } return { content: [{ type: "text", text: JSON.stringify(resource, null, 2), }], isError: false, }; } catch (error) { return getToolError(`Error retrieving asset: ${error.message || "unknown error"}`, cloudinary); } };
  • Zod-based input schema `getAssetToolParams` defining optional parameters for the get-asset tool, including assetId, publicId, resourceType, type, tags, context, and metadata.
    export const getAssetToolParams = { assetId: z.string().optional().describe("The Cloudinary asset ID"), publicId: z.string().optional().describe("The public ID of the asset"), resourceType: z.enum(["image", "raw", "video"]).optional().describe("Type of asset. Default: image"), type: z.enum(["upload", "private", "authenticated", "fetch", "facebook", "twitter", "gravatar", "youtube", "hulu", "vimeo", "animoto", "worldstarhiphop", "dailymotion", "list"]).optional().describe("Delivery type. Default: upload"), tags: z.boolean().optional().describe("Whether to include the list of tag names. Default: false"), context: z.boolean().optional().describe("Whether to include contextual metadata. Default: false"), metadata: z.boolean().optional().describe("Whether to include structured metadata. Default: false"), };
  • src/index.js:57-62 (registration)
    Registers the "get-asset" tool on the MCP server using `server.tool`, providing name, description, input schema, and handler factory.
    server.tool( "get-asset", "Get the details of a specific file (asset)", getAssetToolParams, getGetAssetTool(cloudinary), );
  • Exports the curried handler factory `getGetAssetTool` by wrapping `getAssetTool` with `getCloudinaryTool`.
    export default getCloudinaryTool(getAssetTool);
  • Helper function `getToolError` used to format and return error responses with Cloudinary config details. Note: startLine approximate as preview.
    export const getToolError = (msg, cloudinary) => { const conf = cloudinary.config() return { content: [{ type: "text", text: `${msg} (cloud: ${conf.cloud_name}, key: ${conf.api_key.slice(0,4)}...)`, }],

Other Tools

Related 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