get_latest_series
Fetch the most current data point for a given BLS series ID, providing up-to-date labor statistics like employment or CPI.
Instructions
Retrieve the most recent data point for a given BLS series ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| series_id | Yes | BLS series ID, e.g. LAUCN040010000000005 |
Implementation Reference
- src/tools/series.ts:44-61 (registration)Registration of the 'get_latest_series' MCP tool on the server. Defines the tool name, description, schema (series_id regex-validated string), and the handler callback that delegates to client.getLatestSeries().
server.tool( "get_latest_series", "Retrieve the most recent data point for a given BLS series ID.", { series_id: z .string() .regex(SERIES_ID_PATTERN, "Series ID must be uppercase with no special characters except _, -, #") .describe("BLS series ID, e.g. LAUCN040010000000005"), }, async ({ series_id }) => { try { const data = await client.getLatestSeries(series_id); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return wrapError(error); } } ); - src/tools/series.ts:53-60 (handler)Handler function for the 'get_latest_series' tool. Takes a series_id, calls client.getLatestSeries, returns JSON-stringified data, and catches/ wraps errors using wrapError.
async ({ series_id }) => { try { const data = await client.getLatestSeries(series_id); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return wrapError(error); } } - src/client.ts:71-81 (helper)Client helper method that makes the HTTP GET request to the BLS API endpoint /timeseries/data/{seriesId} with query param { latest: true } to retrieve the most recent data point.
async getLatestSeries(seriesId: string): Promise<unknown> { try { const response = await this.http.get( `/timeseries/data/${seriesId}`, { params: { latest: true } } ); return response.data; } catch (error) { this.handleError(error); } } - src/tools/series.ts:47-52 (schema)Input schema for the 'get_latest_series' tool. Validates that series_id matches the pattern /^[A-Z0-9_#-]+$/.
{ series_id: z .string() .regex(SERIES_ID_PATTERN, "Series ID must be uppercase with no special characters except _, -, #") .describe("BLS series ID, e.g. LAUCN040010000000005"), },