find-assets
Search for existing files in Cloudinary using query expressions to locate images, videos, or raw assets by tags, public IDs, or other criteria.
Instructions
Search for existing files (assets) in Cloudinary with a query expression
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expression | No | Search expression (e.g. 'tags=cat' or 'public_id:folder/*') | |
| resourceType | No | Resource type | image |
| maxResults | No | Maximum number of results | |
| nextCursor | No | Next cursor for pagination | |
| tags | No | Include tags in the response | |
| context | No | Include context in the response |
Implementation Reference
- src/tools/findAssetsTool.js:14-57 (handler)The core handler function that executes the Cloudinary API search for assets based on the provided parameters, handles pagination, and formats the response or error.const findAssetsTool = async (cloudinary, { expression, resourceType, maxResults, nextCursor, tags, context, }) => { try { const options = { expression, resource_type: resourceType, max_results: maxResults, next_cursor: nextCursor, tags, context, }; const result = await cloudinary.api.search(options); if (!result?.total_count) { return { content: [ { type: "text", text: "No assets found matching the search criteria", }, ], isError: false, }; } return { content: [{ type: "text", text: JSON.stringify(result, null, 2), }], isError: false, }; } catch (error) { return getToolError(`Error searching assets: ${error.message}`, cloudinary); } };
- src/tools/findAssetsTool.js:5-12 (schema)Zod-based input schema defining parameters for the 'find-assets' tool, including search expression, resource type, pagination, and response options.export const findAssetsToolParams = { expression: z.string().optional().describe("Search expression (e.g. 'tags=cat' or 'public_id:folder/*')"), resourceType: z.enum(["image", "video", "raw"]).default("image").describe("Resource type"), maxResults: z.number().min(1).max(500).default(10).describe("Maximum number of results"), nextCursor: z.string().optional().describe("Next cursor for pagination"), tags: z.boolean().optional().describe("Include tags in the response"), context: z.boolean().optional().describe("Include context in the response"), };
- src/index.js:67-72 (registration)Registers the 'find-assets' tool on the MCP server, associating it with the schema and the Cloudinary-bound handler.server.tool( "find-assets", "Search for existing files (assets) in Cloudinary with a query expression", findAssetsToolParams, getFindAssetsTool(cloudinary), );