get-usage
Retrieve a detailed report on your Cloudinary product environment usage, including storage, bandwidth, requests, and add-on consumption for a specific date.
Instructions
Get a report on the status of your product environment usage, including storage, credits, bandwidth, requests, number of resources, and add-on usage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | The date for the usage report. Must be within the last 3 months and specified in the format: yyyy-mm-dd. Default: the current date |
Implementation Reference
- src/tools/getUsageTool.js:9-29 (handler)The core handler function for the 'get-usage' tool. It calls Cloudinary's API to fetch usage data for the specified date (optional) and returns a formatted JSON text response or an error.const getUsageTool = async (cloudinary, { date }) => { try { const usageOptions = { date }; const usageResult = await cloudinary.api.usage(usageOptions); return { content: [ { type: "text", text: JSON.stringify(usageResult, null, 2) } ], isError: false, }; } catch (error) { return getToolError(`Error getting usage report from Cloudinary: ${error.message}`, cloudinary); } };
- src/tools/getUsageTool.js:5-7 (schema)Zod schema defining the input parameters for the 'get-usage' tool, specifically an optional 'date' string.export const getUsageToolParams = { date: z.string().optional().describe("The date for the usage report. Must be within the last 3 months and specified in the format: yyyy-mm-dd. Default: the current date") }
- src/index.js:77-82 (registration)Registers the 'get-usage' tool with the MCP server, providing the tool name, description, input schema, and handler function.server.tool( "get-usage", "Get a report on the status of your product environment usage, including storage, credits, bandwidth, requests, number of resources, and add-on usage", getUsageToolParams, getUsageTool(cloudinary), );
- src/tools/getCloudinaryTool.js:1-3 (helper)Helper function that curries tool handlers to accept the Cloudinary instance first, used to wrap the getUsageTool for registration.const getCloudinaryTool = (tool) => { return (cloudinary) => (params) => tool(cloudinary, params); };