UNPKG

@reuvenorg/israel-statistics-mcp

Version:

Model Context Protocol (MCP) server for Israeli Central Bureau of Statistics (CBS) price indices and economic data. Provides 8 comprehensive tools for retrieving, analyzing, and calculating Israeli economic statistics including CPI, housing prices, produc

10 lines (9 loc) 29.2 kB
#!/usr/bin/env node import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'; import de from 'node-fetch'; import le from 'xml2js'; import b, { z as z$1 } from 'zod'; var pe="https://api.cbs.gov.il/";function me(t){return t.trim().startsWith("<?xml")||t.trim().startsWith("<")}async function ue(t){let i=await t.text();if(me(i)){let s=new le.Parser({explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!0});return new Promise((r,d)=>{s.parseString(i,(o,n)=>{o?d(o):r(n);});})}else return JSON.parse(i)}async function l(t,i,s,r){let d=new URL(t,pe);if(Object.entries(i).forEach(([p,m])=>{d.searchParams.append(p,m);}),r&&(r.lang&&d.searchParams.append("lang",r.lang),r.page&&d.searchParams.append("page",r.page.toString()),r.pagesize)){let p=Math.min(r.pagesize,1e3);d.searchParams.append("pagesize",p.toString());}let o=await de(d.toString());if(!o.ok)throw new Error(`CBS API error: ${o.status} ${o.statusText}`);let n=await ue(o);return s.parse(n)}var h=b.enum(["a","aa","b","ba","bb","c","ca","d","e","f","fa"]).describe("Index category filter. Options: a=Consumer Price Index (groceries, retail) | aa=Housing Market Index | b=Producer Price Index Industrial | ba=Producer Price Index Exports | bb=Producer Price Index Services | c=Residential Building Input | ca=Commercial Building Input | d=Road Construction Input | e=Agriculture Input | f=Bus Input | fa=Public Minibus Input. Leave empty for all."),R=b.enum(["he","en"]).describe("Language for response. Options: he=Hebrew (default) | en=English. Use 'en' for English responses."),M=b.enum(["M","Q","MQ","QM"]).describe("Filter indices by update frequency. Options: M=monthly data only | Q=quarterly data only | MQ=both monthly and quarterly (most comprehensive) | QM=quarterly and monthly. Default shows all."),j=b.enum(["begins_with","contains","equals"]).describe("Search matching method. Options: contains=finds text anywhere in name (recommended) | begins_with=name starts with your text | equals=exact name match. Default: contains."),D=b.enum(["new_sheqel","old_sheqel","lira"]).describe("Currency type. Options: new_sheqel=current Israeli Shekel (default, most common) | old_sheqel=pre-1980s Israeli Shekel | lira=historical Israeli Lira."),_=b.enum(["json","xml"]).describe("Response format. Options: json=JSON format (recommended, default) | xml=XML format. Use json unless you specifically need XML."),v=b.boolean().describe("Set to true if you need Hebrew text and the legacy display format. Use false (default) for English text and modern formatting.");var C=z$1.object({total_items:z$1.number().describe("Total number of items"),page_size:z$1.number().describe("Items per page"),current_page:z$1.number().describe("Current page number"),last_page:z$1.number().describe("Last page number"),first_url:z$1.string().nullable().describe("URL for first page"),previous_url:z$1.string().nullable().describe("URL for previous page"),current_url:z$1.string().describe("URL for current page"),next_url:z$1.string().nullable().describe("URL for next page"),last_url:z$1.string().describe("URL for last page"),base_url:z$1.string().nullable().describe("Base URL")}).describe("Pagination information"),z=z$1.object({codeId:z$1.number().describe("Unique numeric identifier for this specific index code"),codeName:z$1.string().describe("Full descriptive name of the index"),codeNote:z$1.string().optional().describe("Additional notes or explanations about this index"),codeLevel:z$1.number().optional().describe("Hierarchical level of this index (1=main, 3=sub, 6=detailed)"),codeLine:z$1.number().optional().describe("Display line number for ordering indices"),codeType:z$1.number().optional().describe("Type classification of the index"),codeFromDate:z$1.string().nullable().optional().describe("Start date when this index became available (YYYY-MM-DD format)"),codeToDate:z$1.string().nullable().optional().describe("End date when this index was discontinued (YYYY-MM-DD format, null if still active)"),codeCalcFromDate:z$1.string().nullable().optional().describe("Start date for index calculations (YYYY-MM-DD format)"),codeCalcToDate:z$1.string().nullable().optional().describe("End date for index calculations (YYYY-MM-DD format, null if still being calculated)"),isMonth:z$1.boolean().optional().describe("Whether this index is updated monthly (true) or at other intervals"),codePrefix:z$1.number().optional().describe("Prefix number used in the index coding system")}),Y=z.extend({codeDescription:z$1.string().optional().nullable().describe("Additional description or notes about this index"),period:z$1.string().optional().nullable().describe("Update frequency period (e.g., 'Monthly', 'Quarterly')"),baseYear:z$1.string().optional().nullable().describe("Base year period for index calculations")}),P=z$1.object({subjectId:z$1.number().describe("Unique numeric identifier for this subject/topic"),subjectName:z$1.string().describe("Descriptive name of the subject/topic area")}),he=P.extend({code:z$1.array(z)}),w=z$1.object({chapterId:h,chapterName:z$1.string().describe("Full descriptive name of the index chapter"),chapterOrder:z$1.number().describe("Display order number for the chapter in the system"),mainCode:z$1.number().nullable().describe("Primary index code for this chapter (null for some chapters that don't have a main index)")}),T=w.extend({subject:z$1.array(he)}),F=z$1.object({value:z$1.number().describe("Index value for this specific base period"),base:z$1.string().describe("Base period description"),chainingCoefficient:z$1.number().optional().describe("Coefficient used for linking indices across different base periods")}),be=z$1.object({year:z$1.number().describe("Year"),month:z$1.number().describe("Month number"),monthDesc:z$1.string().describe("Month name"),percent:z$1.number().describe("Monthly percentage change"),percentYear:z$1.number().describe("Yearly percentage change")}),x=z$1.object({baseDesc:z$1.string().describe("Base period description"),value:z$1.number().describe("Index value")}),fe=be.extend({currBase:x,prevBase:x.nullable().optional()});z$1.object({code:z$1.number().describe("Index code"),name:z$1.string().describe("Index name"),date:z$1.array(fe)});var A=z$1.array(z$1.string());z$1.array(z$1.string()).transform(t=>t.map(i=>parseFloat(i)));z$1.object({_:z$1.string().describe("Index value"),base:A.describe("Base period description"),chainingCoefficient:A.optional().describe("Chaining coefficient for historical linkage")});var B=z$1.object({chapters:z$1.array(T).describe("Array of all index chapters available in the CBS system")}),q=z$1.object({month:z$1.array(z$1.object({code:z$1.number().describe("Index code"),name:z$1.string().describe("Index name in Hebrew"),date:z$1.array(z$1.object({year:z$1.number().describe("Year"),percent:z$1.number().describe("Monthly percentage change"),percentYear:z$1.number().describe("Yearly percentage change"),currBase:x,prevBase:x.nullable().optional(),month:z$1.number().describe("Month number"),monthDesc:z$1.string().describe("Month name in Hebrew")})).describe("Array of date entries with index values")})).nullable().describe("Monthly index data"),quarter:z$1.array(z$1.unknown()).nullable().optional().describe("Quarterly index data (if applicable)"),paging:C}).describe("Index data response containing monthly/quarterly data with pagination"),L=z$1.object({request:z$1.object({code:z$1.number().describe("The index code used for calculation"),sum:z$1.number().describe("The original amount entered for linkage calculation"),currency:z$1.string().describe("Currency type (NEW_SHEQEL, OLD_SHEQEL, LIRA)"),from_date:z$1.string().describe("Starting date for linkage calculation in YYYY-MM-DD format"),to_date:z$1.string().describe("Target date for linkage calculation in YYYY-MM-DD format")}).describe("Request parameters sent to the calculator"),answer:z$1.object({from_value:z$1.number().describe("Original value amount"),to_value:z$1.number().describe("Linked/adjusted value at target date"),base_year:z$1.string().describe("Base year for the index calculation"),from_index_date:z$1.string().describe("Index period corresponding to the from_date"),from_index_value:z$1.number().describe("Index value at the from_date"),to_index_date:z$1.string().describe("Index period corresponding to the to_date"),to_index_value:z$1.number().describe("Index value at the to_date"),chaining_coefficient:z$1.number().describe("Coefficient used for chaining between base years"),mult_min:z$1.number().describe("Minimum multiplication factor"),mult_max:z$1.number().describe("Maximum multiplication factor"),Koeff:z$1.number().describe("Additional coefficient factor"),change_percent:z$1.number().describe("Percentage change from original to linked value")}).describe("Calculation results showing original value linked to target date")}).describe("Price linkage calculation result showing how a monetary amount changes in value over time due to inflation/deflation"),k=z$1.object({chapterId:h,chapterName:z$1.string().nullable().describe("Full descriptive name of the index chapter"),chapterOrder:z$1.number().nullable().describe("Display order number for the chapter in the system"),mainCode:z$1.number().nullable().describe("Primary index code for this chapter"),subject:z$1.array(z$1.object({subjectId:z$1.number().describe("Unique numeric identifier for this subject/topic within the chapter"),subjectName:z$1.string().describe("Descriptive name of the subject/topic area"),code:z$1.any().nullable().describe("Array of index codes for this subject, or null if no codes available")})).describe("Array of subjects/topics available within the specified chapter")}).describe("Topics and subjects available within a specific index chapter from index/catalog/chapter endpoint"),G=P.extend({subjectName:z$1.string().nullable().describe("Descriptive name of the subject/topic area"),chapterId:h.optional().nullable(),chapterName:z$1.string().optional().nullable().describe("Full descriptive name of the parent chapter"),code:z$1.array(Y).describe("Array of index codes available for the specified subject")}).describe("Index codes and details for a specific subject/topic from index/catalog/subject endpoint"),O=z$1.object({indices:z$1.object({"xsi:noNamespaceSchemaLocation":z$1.array(z$1.string()).describe("XML schema location for validation"),"xmlns:xsi":z$1.array(z$1.string()).describe("XML schema instance namespace"),UpdateDate:z$1.array(z$1.string()).describe("Last update timestamp in ISO format"),chapter:z$1.array(z$1.object({name:z$1.array(z$1.string()).describe("Chapter name (e.g., 'Consumer Prices Index')"),month:z$1.array(z$1.object({index:z$1.array(z$1.object({month:z$1.array(z$1.string()).describe("Month name (e.g., 'June')"),year:z$1.array(z$1.string()).describe("Year as string (e.g., '2025')"),code:z$1.array(z$1.string()).describe("Index code (e.g., '120010')"),index_name:z$1.array(z$1.string()).describe("Full index name"),title:z$1.array(z$1.string()).optional().describe("Additional title for some indices"),percent:z$1.array(z$1.string()).optional().describe("Percentage change"),index_base:z$1.array(z$1.object({_:z$1.string().describe("Index value"),base:z$1.array(z$1.string()).describe("Base period (e.g., 'Average 2024')"),chaining_coefficient:z$1.array(z$1.string()).optional().describe("Chaining coefficient for historical linkage")})).optional().describe("Array of index values for different base periods")})).describe("Array of individual index entries")})).optional().describe("Array of month data")})).describe("Array of chapters containing index data")}).describe("Main indices data structure from XML API")}).describe("All indices response from XML API containing nested structure with chapters, months, and index data"),U=z$1.object({indices:z$1.object({UpdateDate:z$1.array(z$1.string()).describe("Last update timestamp of the indices data (ISO format)"),date:z$1.array(z$1.object({year:z$1.array(z$1.string()).describe("Year of the index data (YYYY format)"),month:z$1.array(z$1.string()).describe("Month name of the index data (e.g., 'June', 'July')"),code:z$1.array(z$1.object({code:z$1.array(z$1.string()).describe("Unique numeric index code identifier"),name:z$1.array(z$1.string()).describe("Full descriptive name of the index"),percent:z$1.array(z$1.string()).describe("Monthly percentage change of the index as string"),index:z$1.array(z$1.object({_:z$1.string().describe("Index value for this specific base period"),base:z$1.array(z$1.string()).describe("Base period description (e.g., 'Average 2024', 'Average 2022')"),chainingCoefficient:z$1.array(z$1.string()).optional().describe("Coefficient used for linking indices across different base periods")}))}))}))}).describe("Root indices container with update metadata and date-organized index data")}),$=z$1.object({indices:z$1.object({ind:z$1.array(z$1.object({date:z$1.array(z$1.string()).describe("Date of the index data in YYYY-MM format"),n:z$1.array(z$1.string()).optional().describe("Full descriptive name of the index"),index:z$1.array(z$1.string()).describe("Index value as string (e.g., '102.3')"),percent:z$1.array(z$1.string()).describe("Monthly percentage change as string (e.g., '0.3')"),code:z$1.array(z$1.string()).describe("Unique numeric index code as string (e.g., '120010')"),base:z$1.array(z$1.string()).describe("Base period description (e.g., 'Average 2022')")})).describe("Array of individual index entries")}).describe("Root indices container with array of index data")});z$1.object({topics:z$1.array(T).describe("Array of all index chapters with their topics and codes"),summary:z$1.string().describe("Human-readable summary of the retrieved data, including count of total index codes found")});z$1.object({indices:z$1.array(z$1.object({code:z$1.string().describe("Unique numeric index code identifier (e.g., '120010' for general Consumer Price Index)"),name:z$1.string().describe("Full descriptive name of the index (e.g., 'Consumer Price Index - General')"),percent:z$1.number().describe("Monthly percentage change of the index (positive = increase, negative = decrease)"),year:z$1.string().describe("Year of the index data (YYYY format)"),month:z$1.string().describe("Month name of the index data (e.g., 'June', 'July')"),indices:z$1.array(F)})).describe("Array of main price indices with their values across different base periods"),updateDate:z$1.string().describe("Last update timestamp of the indices data (ISO format)"),summary:z$1.string().describe("Human-readable summary of the retrieved data, including count and update information")});z$1.object({indices:z$1.array(z$1.object({code:z$1.string().describe("Unique numeric index code identifier (e.g., '120010')"),name:z$1.string().describe("Full descriptive name of the index"),percent:z$1.number().describe("Monthly percentage change of the index"),date:z$1.string().describe("Date of the index data in YYYY-MM format"),index:z$1.number().describe("Index value for this period"),base:z$1.string().describe("Base period description (e.g., 'Average 2022')")})).describe("Array of main price indices for the specified period range"),groupedByDate:z$1.record(z$1.string(),z$1.array(z$1.any())).describe("Indices grouped by date for easier navigation"),dateRange:z$1.string().describe("The date range requested (startDate to endDate)"),totalIndices:z$1.number().describe("Total number of indices returned"),summary:z$1.string().describe("Human-readable summary of the data retrieval")});var H=z$1.object({chapters:z$1.array(w).describe("Array of all available index chapters")});z$1.object({indices:z$1.object({UpdateDate:z$1.array(z$1.string()).describe("Last update timestamp"),data:z$1.array(z$1.object({period:z$1.array(z$1.string()).describe("Time period (mm-yyyy format)"),value:z$1.array(z$1.string()).describe("Index value for this period"),coefficient:z$1.array(z$1.string()).optional().describe("Linkage coefficient if requested")}))}).describe("Time series data for a specific index code")});z$1.object({calculator:z$1.object({originalValue:z$1.array(z$1.string()).describe("Original amount provided for calculation"),linkedValue:z$1.array(z$1.string()).describe("Inflation-adjusted amount"),fromDate:z$1.array(z$1.string()).describe("Starting date of calculation"),toDate:z$1.array(z$1.string()).describe("End date of calculation"),indexCode:z$1.array(z$1.string()).describe("Index code used for calculation"),currency:z$1.array(z$1.string()).describe("Currency type used")}).describe("Result of index linkage calculation for inflation adjustment")});z$1.object({month:z$1.array(z$1.object({code:z$1.number().describe("Index code"),name:z$1.string().describe("Index name"),date:z$1.array(z$1.object({year:z$1.number().describe("Year of the data point"),percent:z$1.number().describe("Monthly percentage change"),percentYear:z$1.number().describe("Annual percentage change"),currBase:z$1.object({baseDesc:z$1.string().describe("Base period description"),value:z$1.number().describe("Index value for current base")}),prevBase:z$1.any().nullable().describe("Previous base information"),month:z$1.number().describe("Month number (1-12)"),monthDesc:z$1.string().describe("Month name")})).describe("Array of monthly data points")})).nullable().describe("Monthly data points array"),quarter:z$1.array(z$1.any()).nullable().describe("Quarterly data points (null for monthly data)"),paging:C});function f(t,i,s){let r=[],d=!1;return (t==="aa"||i?.includes("housing")||i?.includes("real")||s?.toLowerCase().includes("housing")||s?.toLowerCase().includes("real estate")||s?.toLowerCase().includes("apartment")||s?.toLowerCase().includes("dwelling"))&&(d=!0,r.push("\u26A0\uFE0F Housing Price Index: This is a bi-monthly index with special publication characteristics."),r.push("\u{1F4CA} Data timing: The published index compares transactions from 2-3 months ago (t-2/t-3) versus 3-4 months ago (t-3/t-4)."),r.push("\u{1F504} Provisional data: The last 3 published indices are provisional and may be updated when additional transaction reports are received."),r.push("\u{1F4A1} Recommendation: For price linkage calculations, avoid using periods where the index is still provisional.")),{isHousingRelated:d,warnings:r}}function g(t,i){if(!i.isHousingRelated)return t;let s=i.warnings.join(" ");return `${t} ${s}`}async function N(t){let i={id:t.code,format:t.format||"json",download:"false"};t.startPeriod&&(i.startPeriod=t.startPeriod),t.endPeriod&&(i.endPeriod=t.endPeriod),t.last&&(i.last=t.last.toString()),t.coef&&(i.coef=t.coef.toString());let s={lang:t.lang,page:t.page,pagesize:t.pagesize},d=await l("index/data/price",i,q,s),o=d.month?.[0]?.date||[],n=o.map(y=>y.currBase.value),p=n.length>0?n.reduce((y,I)=>y+I,0)/n.length:0,m=f(void 0,t.code,d.month?.[0]?.name),S=`Retrieved ${o.length} data points. Average value: ${p.toFixed(2)}.`;return {data:d,summary:g(S,m)}}async function W(t){let i={format:"json",download:"false"};t?.period&&(i.period=t.period),t?.searchText&&(i.q=t.searchText),t?.searchType&&(i.string_match_type=t.searchType);let s={lang:t?.lang,page:t?.page,pagesize:t?.pagesize},r=await l("index/catalog/tree",i,B,s),d=r.chapters.flatMap(o=>o.subject.flatMap(n=>n.code)).length;return {topics:r.chapters,summary:`Found ${d} index codes.`}}async function X(t){let i={lang:t?.lang,page:t?.page,pagesize:t?.pagesize},s=await l("index/catalog/catalog",{format:"json",download:"false"},H,i);return {chapters:s.chapters,summary:`Found ${s.chapters.length} index chapters.`}}async function J(t){let i={lang:t.lang,page:t.page,pagesize:t.pagesize},s=await l("index/catalog/chapter",{id:t.chapterId,format:"json",download:"false"},k,i),r=f(t.chapterId),d=`Found ${s.subject.length} topics in chapter ${t.chapterId}.`;return {topics:s.subject,summary:g(d,r)}}async function E(t){let i={id:t.subjectId.toString(),format:"json",download:"false"};t.searchText&&(i.q=t.searchText),t.searchType&&(i.string_match_type=t.searchType);let s={lang:t.lang,page:t.page,pagesize:t.pagesize},r=await l("index/catalog/subject",i,G,s);return {codes:r.code,summary:`Found ${r.code.length} index codes for subject ${t.subjectId}.`}}async function Q(t){let i={value:t.value.toString(),date:t.fromDate,toDate:t.toDate,format:"json",download:"false"};t.currency&&(i.currency=t.currency);let s={lang:t.lang,page:t.page,pagesize:t.pagesize},r=await l(`index/data/calculator/${t.indexCode}`,i,L,s);return {request:r.request,answer:r.answer,summary:`Linked ${r.request.sum} from ${r.request.from_date} to ${r.request.to_date}: ${r.answer.to_value} (${r.answer.change_percent}% change)`}}async function V(t){let i={format:"json",download:"false"};t?.oldFormat&&(i.oldformat="true");let s={lang:t?.lang,page:t?.page,pagesize:t?.pagesize},r=await l("index/data/price_selected",i,U,s),d=r.indices.date.flatMap(o=>o.code.map(n=>({code:n.code[0],name:n.name[0],percent:parseFloat(n.percent[0]),year:o.year[0],month:o.month[0],indices:n.index.map(p=>({value:parseFloat(p._),base:p.base[0],chainingCoefficient:p.chainingCoefficient?parseFloat(p.chainingCoefficient[0]):void 0}))})));return {indices:d,updateDate:r.indices.UpdateDate[0],summary:`Retrieved ${d.length} main indices updated on ${r.indices.UpdateDate[0]}.`}}async function K(t){let i={StartDate:t.startDate,EndDate:t.endDate,format:"xml",download:"false"},s={lang:t.lang,page:t.page,pagesize:t.pagesize},d=(await l("index/data/price_selected_b",i,$,s)).indices.ind.map(n=>({code:n.code[0],name:n.n?.[0]||"Unknown Index",percent:parseFloat(n.percent[0]),date:n.date[0],index:parseFloat(n.index[0]),base:n.base[0]})),o=d.reduce((n,p)=>{let m=p.date;return n[m]||(n[m]=[]),n[m].push(p),n},{});return {indices:d,groupedByDate:o,dateRange:`${t.startDate} to ${t.endDate}`,totalIndices:d.length,summary:`Retrieved ${d.length} main indices from ${t.startDate} to ${t.endDate}.`}}async function Z(t){let i={format:"xml",download:"false"};t?.oldFormat&&(i.oldformat="true"),t?.chapter&&(i.chapter=t.chapter);let s={lang:t?.lang,page:t?.page,pagesize:t?.pagesize},r=await l("index/data/price_all",i,O,s),d=f(t?.chapter),o=t?.chapter?` for chapter ${t.chapter}`:"",p=`Retrieved ${r.indices.chapter.reduce((m,S)=>m+(S.month?.reduce((y,I)=>y+I.index.length,0)||0),0)} indices${o}.`;return {indices:r.indices,summary:g(p,d)}}var u={lang:R.optional(),page:z$1.number().min(1).optional().describe("Page number for pagination. Start with 1 for first page. Use with pagesize to navigate large result sets."),pagesize:z$1.number().min(1).max(1e3).optional().describe("Number of results per page (maximum 1000). Controls how many items to return. Use with page for pagination.")},ee=z$1.object({period:M.optional(),searchText:z$1.string().optional().describe("Search for specific topics by name. For example, use 'housing' to find housing-related indices, or 'food' for food price indices."),searchType:j.optional(),...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),te=z$1.object({...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),ae=z$1.object({chapterId:h,...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),re=z$1.object({subjectId:z$1.number().describe("The numeric ID of the topic you want index codes for. Get this ID first by calling getChapterTopics or getIndexTopics."),searchText:z$1.string().optional().describe("Filter index codes by description. For example, search 'bread' to find bread-related price indices within the topic."),searchType:j.optional(),...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),ne=z$1.object({indexCode:z$1.number().describe("The numeric index code to use for price linkage calculation. Get this from getIndexData or getSubjectCodes first."),value:z$1.number().describe("The original amount in the currency you want to link/adjust for inflation. For example, 100 for 100 shekels."),fromDate:z$1.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$1.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:D.optional(),...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),ie=z$1.object({oldFormat:v.optional(),...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),oe=z$1.object({startDate:z$1.string().describe("Starting period in yyyymm format, e.g., '202001' for January 2020. Cannot be earlier than 199701 (January 1997)."),endDate:z$1.string().describe("Ending period in yyyymm format, e.g., '202412' for December 2024. Must be later than startDate."),...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),se=z$1.object({oldFormat:v.optional(),chapter:h.optional(),...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")}),ce=z$1.object({code:z$1.string().describe("The index code (numeric string) you want price data for. Get this code first from getSubjectCodes or getIndexTopics. Example: '120010' for general CPI."),startPeriod:z$1.string().optional().describe("Starting period in mm-yyyy format like '01-2020' for January 2020. Leave empty to get data from the beginning of the series."),endPeriod:z$1.string().optional().describe("Ending period in mm-yyyy format like '12-2024' for December 2024. Leave empty to get data up to the most recent available."),format:_.optional(),last:z$1.number().optional().describe("Get only the N most recent data points instead of the full series. Useful for getting just the latest values, e.g., use 12 for the last year of monthly data."),coef:z$1.boolean().optional().describe("Set to true to include linkage coefficients for inflation calculations. Only needed if you plan to do manual price adjustments."),...u,explanation:z$1.string().optional().describe("Additional explanation or context for the request")});async function xe(){console.error("[MCP] Starting israel-statistics-mcp MCP server...");let t=new McpServer({name:"israel-statistics-mcp",version:"1.0.0"},{capabilities:{logging:{},resources:{},tools:{listChanged:!1}}}),i=5,s=0;function r(o){return async(...n)=>{if(s>=i)throw new Error("Too many concurrent operations. Please try again later.");s++;try{return await o(...n)}finally{s--;}}}t.registerTool("get_index_topics",{description:"Get index topics from Israel Statistics API",inputSchema:ee.shape},r(async o=>{let n=await W(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_index_data",{description:"Get index data from Israel Statistics API",inputSchema:ce.shape},r(async o=>{let n=await N(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_catalog_chapters",{description:"Get list of index chapters from Israel Statistics API",inputSchema:te.shape},r(async o=>{let n=await X(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_chapter_topics",{description:"Get topics for a specific chapter from Israel Statistics API",inputSchema:ae.shape},r(async o=>{let n=await J(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_subject_codes",{description:"Get index codes for a specific subject/topic from Israel Statistics API",inputSchema:re.shape},r(async o=>{let n=await E(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_index_calculator",{description:"Calculate price linkage using Israel Statistics API index calculator",inputSchema:ne.shape},r(async o=>{let n=await Q(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_main_indices",{description:"Get main indices by different bases from Israel Statistics API",inputSchema:ie.shape},r(async o=>{let n=await V(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_main_indices_by_period",{description:"Get main indices filtered by period from Israel Statistics API",inputSchema:oe.shape},r(async o=>{let n=await K(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),t.registerTool("get_all_indices",{description:"Get all indices by different bases with optional chapter filtering from Israel Statistics API",inputSchema:se.shape},r(async o=>{let n=await Z(o);return {content:[{type:"text",text:JSON.stringify(n)}]}})),console.error("[MCP] All 8 tools registered successfully");let d=new StdioServerTransport;console.error("[MCP] Created stdio transport"),await t.connect(d),console.error("[MCP] Server connected to stdio transport"),console.error("[MCP] MCP server ready for requests");}process.on("SIGINT",()=>{console.error("[MCP] Received SIGINT, shutting down..."),process.exit(0);});process.on("SIGTERM",()=>{console.error("[MCP] Received SIGTERM, shutting down..."),process.exit(0);});xe().catch(t=>{console.error("[MCP] Fatal error:",t),process.exit(1);}); //# sourceMappingURL=out.js.map //# sourceMappingURL=index.js.map