Skip to main content
Glama

get_main_indices_by_period

Retrieve main economic indices from the Israeli Central Bureau of Statistics (CBS) for a specified time range. Filter data by start and end dates, set language (Hebrew or English), and manage results with pagination.

Instructions

Get main indices filtered by period from Israel Statistics API

Input Schema

NameRequiredDescriptionDefault
endDateYesEnding period in yyyymm format, e.g., '202412' for December 2024. Must be later than startDate.
explanationNoAdditional explanation or context for the request
langNoLanguage for response. Options: he=Hebrew (default) | en=English. Use 'en' for English responses.
pageNoPage number for pagination. Start with 1 for first page. Use with pagesize to navigate large result sets.
pagesizeNoNumber of results per page (maximum 1000). Controls how many items to return. Use with page for pagination.
startDateYesStarting period in yyyymm format, e.g., '202001' for January 2020. Cannot be earlier than 199701 (January 1997).

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "endDate": { "description": "Ending period in yyyymm format, e.g., '202412' for December 2024. Must be later than startDate.", "type": "string" }, "explanation": { "description": "Additional explanation or context for the request", "type": "string" }, "lang": { "description": "Language for response. Options: he=Hebrew (default) | en=English. Use 'en' for English responses.", "enum": [ "he", "en" ], "type": "string" }, "page": { "description": "Page number for pagination. Start with 1 for first page. Use with pagesize to navigate large result sets.", "minimum": 1, "type": "number" }, "pagesize": { "description": "Number of results per page (maximum 1000). Controls how many items to return. Use with page for pagination.", "maximum": 1000, "minimum": 1, "type": "number" }, "startDate": { "description": "Starting period in yyyymm format, e.g., '202001' for January 2020. Cannot be earlier than 199701 (January 1997).", "type": "string" } }, "required": [ "startDate", "endDate" ], "type": "object" }

Implementation Reference

  • The main handler function that fetches main indices data for a specified period using secureFetch, transforms the XML response, groups data by date, and returns structured results including indices list, grouped view, and summary.
    export async function getMainIndicesByPeriod( args: z.infer<typeof getMainIndicesByPeriodSchema> ): Promise<TransformedMainIndicesByPeriodResponse> { const params = { StartDate: args.startDate, EndDate: args.endDate, format: "xml", download: "false", } // Extract global parameters const globalParams: GlobalParams = { lang: args.lang, page: args.page, pagesize: args.pagesize, } const data = await secureFetch( "index/data/price_selected_b", params, mainIndicesByPeriodXmlResponseSchema, globalParams ) // Transform XML data to a more usable format const transformedIndices = data.indices.ind.map((indEntry) => ({ code: indEntry.code[0], // Get first element from array name: indEntry.n?.[0] || "Unknown Index", // Get first element from array (note: 'n', not 'name') percent: parseFloat(indEntry.percent[0]), // Get first element from array date: indEntry.date[0], // Get first element from array (YYYY-MM format) index: parseFloat(indEntry.index[0]), // Index value as number base: indEntry.base[0], // Base period description })) // Group by date for better organization const groupedByDate = transformedIndices.reduce( (acc, curr) => { const date = curr.date if (!acc[date]) { acc[date] = [] } acc[date].push(curr) return acc }, {} as Record<string, typeof transformedIndices> ) return { indices: transformedIndices, groupedByDate, dateRange: `${args.startDate} to ${args.endDate}`, totalIndices: transformedIndices.length, summary: `Retrieved ${transformedIndices.length} main indices from ${args.startDate} to ${args.endDate}.`, } }
  • Zod schema defining input validation for the tool, requiring startDate and endDate in yyyymm format, optional global parameters (lang, page, pagesize), and explanation.
    export const getMainIndicesByPeriodSchema = z.object({ startDate: z .string() .describe( "Starting period in yyyymm format, e.g., '202001' for January 2020. Cannot be earlier than 199701 (January 1997)." ), endDate: z .string() .describe( "Ending period in yyyymm format, e.g., '202412' for December 2024. Must be later than startDate." ), ...globalParamsSchema, explanation: z .string() .optional() .describe("Additional explanation or context for the request"), })
  • src/index.ts:206-224 (registration)
    MCP server tool registration for 'get_main_indices_by_period', specifying description, input schema from getMainIndicesByPeriodSchema, and wrapped handler call with rate limiting.
    server.registerTool( "get_main_indices_by_period", { description: "Get main indices filtered by period from Israel Statistics API", inputSchema: getMainIndicesByPeriodSchema.shape, }, withRateLimit(async (args) => { const result = await getMainIndicesByPeriod(args) return { content: [ { type: "text", text: JSON.stringify(result), }, ], } }) )

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/reuvenaor/israel-statistics-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server