get_single_series
Get data for a single BLS time series for the past three years. Provide a valid series ID to access employment, CPI, or wage statistics.
Instructions
Retrieve data for a single BLS time series for the past three years. Provide a valid BLS series ID (uppercase letters, numbers, underscores, dashes, hashes only).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| series_id | Yes | BLS series ID, e.g. LAUCN040010000000005 |
Implementation Reference
- src/client.ts:60-69 (handler)The getSingleSeries method on the Client class that makes the actual HTTP GET request to the BLS API endpoint /timeseries/data/{seriesId} and returns the response data.
async getSingleSeries(seriesId: string): Promise<unknown> { try { const response = await this.http.get( `/timeseries/data/${seriesId}` ); return response.data; } catch (error) { this.handleError(error); } } - src/tools/series.ts:28-33 (schema)The input schema (Zod validation) for the 'get_single_series' tool — validates the series_id parameter against the SERIES_ID_PATTERN regex.
{ 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"), }, - src/tools/series.ts:23-42 (registration)The registration of the 'get_single_series' tool via server.tool() inside the registerSeriesTools function, including its description, schema, and handler callback.
export function registerSeriesTools(server: McpServer, client: Client) { server.tool( "get_single_series", "Retrieve data for a single BLS time series for the past three years. " + "Provide a valid BLS series ID (uppercase letters, numbers, underscores, dashes, hashes only).", { 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.getSingleSeries(series_id); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return wrapError(error); } } ); - src/index.ts:15-16 (registration)The call to registerSeriesTools(server, client) which registers the 'get_single_series' tool at server startup.
registerSeriesTools(server, client); registerSurveyTools(server, client); - src/tools/series.ts:5-19 (helper)The wrapError helper used in the tool handler to format BlsApiError and unexpected errors into the MCP content response format.
function wrapError(error: unknown): { content: { type: "text"; text: string }[] } { if (error instanceof BlsApiError) { return { content: [ { type: "text" as const, text: `Error: ${error.message}${error.isRateLimit ? "\nConsider setting BLS_API_KEY for higher rate limits." : ""}`, }, ], }; } return { content: [{ type: "text" as const, text: `Unexpected error: ${String(error)}` }], }; }