get_all_surveys
Retrieve the complete list of BLS surveys, each with its abbreviation and name, for use in data queries.
Instructions
Retrieve a list of all BLS surveys with their abbreviations and names.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/surveys.ts:43-55 (handler)The MCP tool handler for 'get_all_surveys'. Registers a tool with no parameters that calls client.getAllSurveys() and returns the JSON response.
server.tool( "get_all_surveys", "Retrieve a list of all BLS surveys with their abbreviations and names.", {}, async () => { try { const data = await client.getAllSurveys(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return wrapError(error); } } ); - src/tools/surveys.ts:21-75 (registration)The registerSurveyTools function that registers three survey-related tools (including get_all_surveys) on the McpServer via server.tool().
export function registerSurveyTools(server: McpServer, client: Client) { server.tool( "get_popular_series", "Retrieve the 25 most popular BLS series IDs overall or for a specific survey. " + "Optionally provide a survey abbreviation to filter by survey.", { survey: z .string() .regex(/^[A-Z]{2}$/, "Survey abbreviation must be exactly 2 uppercase letters") .optional() .describe("Optional 2-letter survey abbreviation, e.g. LA, CU, CE"), }, async ({ survey }) => { try { const data = await client.getPopularSeries(survey); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return wrapError(error); } } ); server.tool( "get_all_surveys", "Retrieve a list of all BLS surveys with their abbreviations and names.", {}, async () => { try { const data = await client.getAllSurveys(); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return wrapError(error); } } ); server.tool( "get_survey", "Retrieve metadata for a single BLS survey by its abbreviation.", { survey_abbreviation: z .string() .regex(/^[A-Z]{2}$/, "Survey abbreviation must be exactly 2 uppercase letters") .describe("Survey abbreviation, e.g. TU, CU, LA"), }, async ({ survey_abbreviation }) => { try { const data = await client.getSurvey(survey_abbreviation); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (error) { return wrapError(error); } } ); } - src/client.ts:109-116 (helper)The Client.getAllSurveys() method that makes the actual HTTP GET request to /surveys on the BLS API and returns the response data.
async getAllSurveys(): Promise<unknown> { try { const response = await this.http.get("/surveys"); return response.data; } catch (error) { this.handleError(error); } } - src/index.ts:5-5 (registration)Import of registerSurveyTools from ./tools/surveys.js in the main entry point.
import { registerSurveyTools } from "./tools/surveys.js"; - src/index.ts:16-16 (registration)Call to registerSurveyTools(server, client) in the main entry point, which registers the tool on the MCP server.
registerSurveyTools(server, client);