get_survey
Retrieve metadata for a specific BLS survey by providing its two-letter abbreviation, such as TU, CU, or LA.
Instructions
Retrieve metadata for a single BLS survey by its abbreviation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| survey_abbreviation | Yes | Survey abbreviation, e.g. TU, CU, LA |
Implementation Reference
- src/tools/surveys.ts:57-74 (registration)Registration of the 'get_survey' tool with MCP server, including schema definition and handler.
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/tools/surveys.ts:60-65 (schema)Zod schema for the input parameter 'survey_abbreviation' — required, 2 uppercase letters.
{ survey_abbreviation: z .string() .regex(/^[A-Z]{2}$/, "Survey abbreviation must be exactly 2 uppercase letters") .describe("Survey abbreviation, e.g. TU, CU, LA"), }, - src/tools/surveys.ts:66-73 (handler)Handler function that calls client.getSurvey() and returns the result as JSON string.
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:118-127 (helper)Client method that makes the actual HTTP GET request to /surveys/{surveyAbbreviation} on the BLS API.
async getSurvey(surveyAbbreviation: string): Promise<unknown> { try { const response = await this.http.get( `/surveys/${surveyAbbreviation}` ); return response.data; } catch (error) { this.handleError(error); } } - src/index.ts:16-16 (registration)Entry-point registration call that wires up all survey tools including 'get_survey'.
registerSurveyTools(server, client);