get_subject_codes
Retrieve index codes for specific topics from Israel Statistics API using numeric subject IDs. Filter results by description, control pagination, and choose response language (English or Hebrew).
Instructions
Get index codes for a specific subject/topic from Israel Statistics API
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| explanation | No | Additional explanation or context for the request | |
| 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. | |
| 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. | |
| subjectId | Yes | The numeric ID of the topic you want index codes for. Get this ID first by calling getChapterTopics or getIndexTopics. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"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"
},
"searchText": {
"description": "Filter index codes by description. For example, search 'bread' to find bread-related price indices within the topic.",
"type": "string"
},
"searchType": {
"description": "Search matching method. Options: contains=finds text anywhere in name (recommended) | begins_with=name starts with your text | equals=exact name match. Default: contains.",
"enum": [
"begins_with",
"contains",
"equals"
],
"type": "string"
},
"subjectId": {
"description": "The numeric ID of the topic you want index codes for. Get this ID first by calling getChapterTopics or getIndexTopics.",
"type": "number"
}
},
"required": [
"subjectId"
],
"type": "object"
}
Implementation Reference
- src/mcp/handlers/getSubjectCodes.ts:6-35 (handler)The main handler function that implements the logic for the get_subject_codes tool. It constructs API parameters based on input args, calls secureFetch to retrieve data from the 'index/catalog/subject' endpoint, 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 schema defining the input validation for the get_subject_codes tool, including subjectId, optional searchText, searchType, global pagination params, 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)Registers the get_subject_codes tool with the MCP server, providing its description, input schema, and a rate-limited wrapper around the handler function.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), }, ], } }) )