get_resource_packages
Retrieve Kling AI resource package details to monitor API credits, track expiration dates, and plan usage allocation for video generation tasks.
Instructions
Get detailed information about your Kling AI resource packages including remaining credits, expiration dates, and package types. Useful for monitoring API usage and planning resource allocation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/kling-client.ts:453-465 (handler)The core handler function that fetches the user's resource packages from the Kling AI API endpoint '/v1/account/packages' and returns them as ResourcePackage[]async getResourcePackages(): Promise<ResourcePackage[]> { const path = '/v1/account/packages'; try { const response = await this.axiosInstance.get(path); return response.data.data.resource_packages || []; } catch (error) { if (axios.isAxiosError(error)) { throw new Error(`Kling API error: ${error.response?.data?.message || error.message}`); } throw error; } }
- src/index.ts:699-725 (registration)MCP tool dispatch handler that calls klingClient.getResourcePackages() and formats the response as a readable text summary of the packages.case 'get_resource_packages': { const packages = await klingClient.getResourcePackages(); let packagesText = 'Your Kling AI Resource Packages:\n'; if (packages.length === 0) { packagesText += '\nNo active resource packages found.'; } else { packages.forEach((pkg, index) => { packagesText += `\n\nPackage ${index + 1}:`; packagesText += `\n- Name: ${pkg.name}`; packagesText += `\n- Resource ID: ${pkg.resource_id}`; packagesText += `\n- Amount: ${pkg.amount}`; packagesText += `\n- Expires: ${new Date(pkg.expire_at).toLocaleString()}`; packagesText += `\n- Created: ${new Date(pkg.created_at).toLocaleString()}`; }); } return { content: [ { type: 'text', text: packagesText, }, ], }; }
- src/index.ts:413-421 (schema)Tool registration in the TOOLS array, including the name, description, and empty inputSchema (no parameters required). Used by ListToolsRequest.{ name: 'get_resource_packages', description: 'Get detailed information about your Kling AI resource packages including remaining credits, expiration dates, and package types. Useful for monitoring API usage and planning resource allocation.', inputSchema: { type: 'object', properties: {}, required: [], }, },
- src/kling-client.ts:96-102 (schema)TypeScript interface defining the structure of a ResourcePackage returned by the handler.export interface ResourcePackage { resource_id: string; name: string; amount: number; expire_at: string; created_at: string; }