create_invoice_vat
Create a VAT rate for invoices by specifying its name and percentage.
Instructions
Create an invoice vat.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the invoice vat. | |
| percentage | Yes | Number representing the VAT percentage. |
Implementation Reference
- src/tools/invoice_vats.ts:43-51 (handler)The async handler function for the 'create_invoice_vat' tool. It receives the validated input body (name, percentage), calls apiPost to POST to '/invoice_vats', logs the response, and formats the result via formatCreate.
async (body) => { try { const record = await apiPost<EduframeRecord>("/invoice_vats", body); void logResponse("create_invoice_vat", body, record); return formatCreate(record, "invoice vat"); } catch (error) { return formatError(error); } }, - src/tools/invoice_vats.ts:35-42 (schema)Input schema for 'create_invoice_vat'. Requires 'name' (string) and 'percentage' (string representing VAT percentage).
{ description: "Create an invoice vat.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, inputSchema: { name: z.string().describe("Name of the invoice vat."), percentage: z.string().describe("Number representing the VAT percentage."), }, }, - src/tools/invoice_vats.ts:33-52 (registration)Registration of 'create_invoice_vat' via server.registerTool() with its name, metadata (description, annotations), schema, and handler.
server.registerTool( "create_invoice_vat", { description: "Create an invoice vat.", annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, inputSchema: { name: z.string().describe("Name of the invoice vat."), percentage: z.string().describe("Number representing the VAT percentage."), }, }, async (body) => { try { const record = await apiPost<EduframeRecord>("/invoice_vats", body); void logResponse("create_invoice_vat", body, record); return formatCreate(record, "invoice vat"); } catch (error) { return formatError(error); } }, ); - src/api.ts:163-174 (helper)The apiPost helper function used by the handler to make the POST request to the Eduframe API.
export async function apiPost<T>(path: string, body: unknown): Promise<T> { const { token } = getConfig(); const url = buildUrl(path); const response = await fetch(url.toString(), { method: "POST", headers: buildHeaders(token), body: JSON.stringify(body), }); return handleResponse<T>(response); } - src/formatters.ts:85-94 (helper)The formatCreate helper used by the handler to format the created resource as a success message.
export function formatCreate(record: EduframeRecord, resourceName: string): CallToolResult { return { content: [ { type: "text", text: `Successfully created ${resourceName}:\n\n${formatJSON(record)}${RESPONSE_LOG_HINT}`, }, ], }; }