get_statement
Retrieve Monobank transaction statements for specified accounts and date ranges to analyze financial activity and track spending patterns.
Instructions
Get Monobank statement for the time from {from} to {to} time in seconds in Unix time format. The maximum time for which it is posssible to obtain a statement is 31 days + 1 hour (2682000 seconds). The statement can be retrieved not more than once per 60 seconds, otherwise an error will be thrown.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes |
Implementation Reference
- src/index.ts:64-115 (handler)The 'get_statement' tool is registered and implemented directly in src/index.ts. It defines the input schema using zod and handles the logic for fetching statements from the Monobank API, including date validation, request formatting, and response parsing.
server.tool( "get_statement", "Get Monobank statement for the time from {from} to {to} time in seconds in Unix time format. The maximum time for which it is posssible to obtain a statement is 31 days + 1 hour (2682000 seconds). The statement can be retrieved not more than once per 60 seconds, otherwise an error will be thrown.", { input: z.object({ account: z .string() .nonempty() .describe( "A unique indentificator of the Monobank account or a jar from the Statement list. If not provided, then a defaukt account is used, which is equal to '0'.", ), from: z .string() .nonempty() .describe("A date in ISO 8601 YYYY-MM-DD format."), to: z .string() .optional() .describe("A date in ISO 8601 YYYY-MM-DD format."), }), }, async ({ input }) => { try { const { account, from, to } = input; const dateValidation = validateStatementDates(from, to); if ("content" in dateValidation) { return dateValidation; } const { fromInSeconds, toInSeconds } = dateValidation; const { baseUrl, monobankApiToken } = getConfig(); const response = await fetchWithErrorHandling( `${baseUrl}/personal/statement/${account}/${fromInSeconds}/${toInSeconds}`, { headers: { "X-Token": monobankApiToken, }, }, ); const data = await parseJsonResponse<StatementItem[]>(response); const statement = z.array(StatementItemSchema).parse(data); const formattedStatement = formatStatementItems(statement); return createSuccessResponse(formattedStatement); } catch (error) { return formatErrorAsToolResponse(error, "fetch statement"); } }, );