get_index_calculator
Calculate price linkage and adjust amounts for inflation using Israel Statistics data. Convert values between dates based on index codes for accurate financial analysis.
Instructions
Calculate price linkage using Israel Statistics API index calculator
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexCode | Yes | The numeric index code to use for price linkage calculation. Get this from getIndexData or getSubjectCodes first. | |
| value | Yes | The original amount in the currency you want to link/adjust for inflation. For example, 100 for 100 shekels. | |
| fromDate | Yes | Starting date for the linkage calculation in mm-dd-yyyy format (e.g., '01-01-2020'). This is when your original amount was valued. | |
| toDate | Yes | Target date for the linkage calculation in mm-dd-yyyy format (e.g., '01-01-2024'). This shows what the amount is worth at this later date. | |
| currency | No | Currency type. Options: new_sheqel=current Israeli Shekel (default, most common) | old_sheqel=pre-1980s Israeli Shekel | lira=historical Israeli Lira. | |
| lang | No | Language for response. Options: he=Hebrew (default) | en=English. Use 'en' for English responses. | |
| page | No | Page number for pagination. Start with 1 for first page. Use with pagesize to navigate large result sets. | |
| pagesize | No | Number of results per page (maximum 1000). Controls how many items to return. Use with page for pagination. | |
| explanation | No | Additional explanation or context for the request |
Implementation Reference
- The handler function implementing the core logic for the get_index_calculator tool, which fetches index calculator data from the API using secureFetch and returns formatted request, answer, and summary.export async function getIndexCalculator( args: z.infer<typeof getIndexCalculatorSchema> ) { const params: Record<string, string> = { value: args.value.toString(), date: args.fromDate, toDate: args.toDate, format: "json", download: "false", } if (args.currency) params.currency = args.currency // Extract global parameters const globalParams: GlobalParams = { lang: args.lang, page: args.page, pagesize: args.pagesize, } const data = await secureFetch( `index/data/calculator/${args.indexCode}`, params, indexCalculatorResponseSchema, globalParams ) return { request: data.request, answer: data.answer, summary: `Linked ${data.request.sum} from ${data.request.from_date} to ${data.request.to_date}: ${data.answer.to_value} (${data.answer.change_percent}% change)`, } }
- src/schemas/request.schema.ts:85-112 (schema)Input schema using Zod for validating parameters of the get_index_calculator tool, including indexCode, value, dates, currency, and global params.export const getIndexCalculatorSchema = z.object({ indexCode: z .number() .describe( "The numeric index code to use for price linkage calculation. Get this from getIndexData or getSubjectCodes first." ), value: z .number() .describe( "The original amount in the currency you want to link/adjust for inflation. For example, 100 for 100 shekels." ), fromDate: z .string() .describe( "Starting date for the linkage calculation in mm-dd-yyyy format (e.g., '01-01-2020'). This is when your original amount was valued." ), toDate: z .string() .describe( "Target date for the linkage calculation in mm-dd-yyyy format (e.g., '01-01-2024'). This shows what the amount is worth at this later date." ), currency: currencySchema.optional(), ...globalParamsSchema, explanation: z .string() .optional() .describe("Additional explanation or context for the request"), })
- src/index.ts:166-184 (registration)MCP tool registration for 'get_index_calculator', specifying description, input schema, and handler invocation wrapped in rate limiting.server.registerTool( "get_index_calculator", { description: "Calculate price linkage using Israel Statistics API index calculator", inputSchema: getIndexCalculatorSchema.shape, }, withRateLimit(async (args) => { const result = await getIndexCalculator(args) return { content: [ { type: "text", text: JSON.stringify(result), }, ], } }) )