get_subject_codes
Retrieve index codes for specific topics from Israel's Central Bureau of Statistics data. Filter results by search text and language, with pagination for large datasets.
Instructions
Get index codes for a specific subject/topic from Israel Statistics API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subjectId | Yes | The numeric ID of the topic you want index codes for. Get this ID first by calling getChapterTopics or getIndexTopics. | |
| searchText | No | Filter index codes by description. For example, search 'bread' to find bread-related price indices within the topic. | |
| searchType | No | Search matching method. Options: contains=finds text anywhere in name (recommended) | begins_with=name starts with your text | equals=exact name match. Default: contains. | |
| 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
- src/mcp/handlers/getSubjectCodes.ts:6-35 (handler)The main handler function that executes the tool logic: fetches index codes for a subject from the Israel Statistics API using secureFetch, processes parameters, and returns the codes with a summary.export async function getSubjectCodes( args: z.infer<typeof getSubjectCodesSchema> ) { const params: Record<string, string> = { id: args.subjectId.toString(), format: "json", download: "false", } if (args.searchText) params.q = args.searchText if (args.searchType) params.string_match_type = args.searchType // Extract global parameters const globalParams: GlobalParams = { lang: args.lang, page: args.page, pagesize: args.pagesize, } const data = await secureFetch( "index/catalog/subject", params, subjectCodesResponseSchema, globalParams ) return { codes: data.code, summary: `Found ${data.code.length} index codes for subject ${args.subjectId}.`, } }
- src/schemas/request.schema.ts:65-83 (schema)Zod input schema defining parameters for get_subject_codes: subjectId (required), optional searchText, searchType, pagination (page, pagesize), lang, and explanation.export const getSubjectCodesSchema = z.object({ subjectId: z .number() .describe( "The numeric ID of the topic you want index codes for. Get this ID first by calling getChapterTopics or getIndexTopics." ), searchText: z .string() .optional() .describe( "Filter index codes by description. For example, search 'bread' to find bread-related price indices within the topic." ), searchType: searchTypeSchema.optional(), ...globalParamsSchema, explanation: z .string() .optional() .describe("Additional explanation or context for the request"), })
- src/index.ts:146-164 (registration)MCP tool registration: registers 'get_subject_codes' with description, input schema, and wrapped handler (with rate limiting) that calls getSubjectCodes and formats response.server.registerTool( "get_subject_codes", { description: "Get index codes for a specific subject/topic from Israel Statistics API", inputSchema: getSubjectCodesSchema.shape, }, withRateLimit(async (args) => { const result = await getSubjectCodes(args) return { content: [ { type: "text", text: JSON.stringify(result), }, ], } }) )