get_resource_packages
Retrieve details about Kling AI resource packages, such as remaining credits, expiration dates, and types, to monitor API usage and optimize resource allocation.
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)Core handler function that makes the API request to /v1/account/packages and returns the ResourcePackage array.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:413-421 (registration)MCP tool registration in the TOOLS array, defining name, description, and empty input schema.{ 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/index.ts:699-725 (handler)MCP CallToolRequest handler case that invokes the klingClient method and formats the response as MCP content.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/kling-client.ts:96-102 (schema)TypeScript interface defining the structure of ResourcePackage objects returned by the tool.export interface ResourcePackage { resource_id: string; name: string; amount: number; expire_at: string; created_at: string; }