allocate_credits
Allocate credits to a client by specifying client ID, credit type, and amount. Optionally add source and notes for tracking.
Instructions
Allocate credits to a client.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| client_id | Yes | Client ID | |
| credit_type | Yes | Credit type | |
| amount | Yes | Number of credits | |
| source | No | Source (e.g. bonus) | |
| notes | No | Notes |
Implementation Reference
- server/index.js:786-804 (registration)Registration of the 'allocate_credits' tool via server.tool() with name, description, schema, metadata, and handler callback.
server.tool( "allocate_credits", "Allocate credits to a client.", { client_id: z.string().describe("Client ID"), credit_type: z.enum(["monthly", "purchased", "daily"]).describe("Credit type"), amount: z.number().describe("Number of credits"), source: z.string().optional().describe("Source (e.g. bonus)"), notes: z.string().optional().describe("Notes"), }, { title: "Allocate Credits", readOnlyHint: false, destructiveHint: false, openWorldHint: false }, async ({ client_id, credit_type, amount, source, notes }) => { const body = { client_id, credit_type, amount }; if (source) body.source = source; if (notes) body.notes = notes; const data = await apiCall("/v1/ai/credits/client/allocate", "POST", body); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } ); - server/index.js:797-803 (handler)Handler function that builds the request body (client_id, credit_type, amount, optional source/notes) and calls POST /v1/ai/credits/client/allocate.
async ({ client_id, credit_type, amount, source, notes }) => { const body = { client_id, credit_type, amount }; if (source) body.source = source; if (notes) body.notes = notes; const data = await apiCall("/v1/ai/credits/client/allocate", "POST", body); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } - server/index.js:789-795 (schema)Zod schema defining inputs: client_id (string), credit_type (enum: monthly/purchased/daily), amount (number), source (optional string), notes (optional string).
{ client_id: z.string().describe("Client ID"), credit_type: z.enum(["monthly", "purchased", "daily"]).describe("Credit type"), amount: z.number().describe("Number of credits"), source: z.string().optional().describe("Source (e.g. bonus)"), notes: z.string().optional().describe("Notes"), }, - server/index.js:112-123 (helper)The apiCall helper function used by the handler to make authenticated HTTP requests to the Lindo AI API.
async function apiCall(path, method, body) { const url = `${BASE_URL}${path}`; const res = await fetch(url, { method, headers: { Authorization: `Bearer ${API_KEY}`, "Content-Type": "application/json", }, ...(body ? { body: JSON.stringify(body) } : {}), }); return res.json(); }