set_default_currency
Set the company's default currency by providing a global currency ID. Creates the currency if needed, but fails if invoices already use it.
Instructions
Set the company default currency. POST /currencies/default. Required: currencyId (global currency ID). Creates company currency if needed. Fails if there are invoices with that currency.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| currencyId | Yes | Global currency ID (required) |
Implementation Reference
- The handler function that executes the 'set_default_currency' tool logic. It validates args with a Zod schema, then calls currencyService.setDefaultCurrency with the provided currencyId.
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } return handleToolCall(() => currencyService.setDefaultCurrency(client, { currencyId: parsed.data.currencyId }) ); } - Zod validation schema for set_default_currency. Requires a positive integer currencyId.
const schema = z.object({ currencyId: z.number().int().positive("currencyId is required (global currency ID)"), }); - The tool definition/input schema for MCP (name 'set_default_currency', description, and JSON Schema inputSchema requiring a number currencyId).
const definition = { name: "set_default_currency", description: "Set the company default currency. POST /currencies/default. Required: currencyId (global currency ID). Creates company currency if needed. Fails if there are invoices with that currency.", inputSchema: { type: "object" as const, properties: { currencyId: { type: "number", description: "Global currency ID (required)" }, }, required: ["currencyId"], }, }; - src/tools/currencies/setDefaultCurrency.ts:34-37 (registration)Export of the setDefaultCurrencyTool object (Tool type with definition and handler) which is imported and registered in the tools index.
export const setDefaultCurrencyTool: Tool = { definition, handler, }; - The underlying service function that makes the POST /currencies/default API call with the currencyId body.
export async function setDefaultCurrency( client: Client, body: SetDefaultCurrencyBody ): Promise<unknown> { return client.post<unknown>("/currencies/default", body); }