add_consumption
Increase consumption units for a specific license by providing the license key, hardware ID, product, and consumption value. Manage overages and usage limits effectively with this tool.
Instructions
Add consumption units to a license
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| allow_overages | No | ||
| consumptions | Yes | ||
| hardware_id | Yes | ||
| license_key | Yes | ||
| max_overages | No | ||
| product | Yes |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"allow_overages": {
"type": "boolean"
},
"consumptions": {
"minimum": 1,
"type": "number"
},
"hardware_id": {
"minLength": 1,
"type": "string"
},
"license_key": {
"minLength": 1,
"type": "string"
},
"max_overages": {
"type": "number"
},
"product": {
"minLength": 1,
"type": "string"
}
},
"required": [
"license_key",
"hardware_id",
"product",
"consumptions"
],
"type": "object"
}
Implementation Reference
- src/license-api-server.ts:332-357 (handler)The handler function that implements the 'add_consumption' tool logic. It sends a POST request to the LicenseSpring License API endpoint '/api/v4/add_consumption' with the provided parameters and returns the API response or error.}, async ({ license_key, hardware_id, product, consumptions, max_overages, allow_overages }) => { try { const response = await apiClient.post('/api/v4/add_consumption', { license_key, hardware_id, product, consumptions, max_overages, allow_overages, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2), }], }; } catch (error) { return { content: [{ type: 'text', text: `Error adding consumption: ${handleApiError(error)}`, }], isError: true, }; }
- src/license-api-server.ts:324-331 (schema)Zod input schema validation for the 'add_consumption' tool parameters.inputSchema: { license_key: z.string().min(1, 'License key is required'), hardware_id: z.string().min(1, 'Hardware ID is required'), product: z.string().min(1, 'Product code is required'), consumptions: z.number().min(1, 'Consumption units must be positive'), max_overages: z.number().optional(), allow_overages: z.boolean().optional(), },
- src/license-api-server.ts:321-358 (registration)Registration of the 'add_consumption' MCP tool with schema and handler function.server.registerTool('add_consumption', { title: 'Add Consumption', description: 'Add consumption units to a license', inputSchema: { license_key: z.string().min(1, 'License key is required'), hardware_id: z.string().min(1, 'Hardware ID is required'), product: z.string().min(1, 'Product code is required'), consumptions: z.number().min(1, 'Consumption units must be positive'), max_overages: z.number().optional(), allow_overages: z.boolean().optional(), }, }, async ({ license_key, hardware_id, product, consumptions, max_overages, allow_overages }) => { try { const response = await apiClient.post('/api/v4/add_consumption', { license_key, hardware_id, product, consumptions, max_overages, allow_overages, }); return { content: [{ type: 'text', text: JSON.stringify(response.data, null, 2), }], }; } catch (error) { return { content: [{ type: 'text', text: `Error adding consumption: ${handleApiError(error)}`, }], isError: true, }; } });
- src/types/index.ts:33-40 (schema)TypeScript interface defining the request shape for add_consumption, used for typing the API client requests.export interface AddConsumptionRequest { license_key: string; hardware_id: string; product: string; consumptions: number; max_overages?: number; allow_overages?: boolean; }