getProcedureStep
Retrieve specific step details from a procedure using procedure and step IDs. Enables AI systems to access structured eRegulations data for accurate administrative procedure queries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| procedureId | Yes | ID of the procedure | |
| stepId | Yes | ID of the step within the procedure |
Implementation Reference
- The main handler function createGetProcedureStepHandler that implements the tool logic: validates args, calls the API to get the step, formats it using formatters.step.format, and returns formatted text content or error.export function createGetProcedureStepHandler( api: ERegulationsApi ): ToolHandler { return { name: ToolName.GET_PROCEDURE_STEP, description: `Get information about a specific step within a procedure.`, inputSchema: zodToJsonSchema(GetProcedureStepSchema), inputSchemaDefinition: GetProcedureStepSchema, handler: async (args: any) => { try { // Use the inferred type for args const { procedureId, stepId } = args as GetProcedureStepArgs; logger.log( `Handling GET_PROCEDURE_STEP request for procedure ${procedureId}, step ${stepId}` ); const step = await api.getProcedureStep(procedureId, stepId); // Use the step formatter - get result (data part ignored) const formattedResult = formatters.step.format(step); logger.log(`GET_PROCEDURE_STEP returning step ${step.name}`); // Always return only text content return { content: [ { type: "text", text: formattedResult.text, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error retrieving step details: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }, }; }
- Zod schema for input validation of getProcedureStep tool, requiring procedureId and stepId as numbers.export const GetProcedureStepSchema = z.object({ procedureId: z.number().describe("ID of the procedure"), stepId: z.number().describe("ID of the step within the procedure"), });
- src/mcp-capabilities/tools/handlers/index.ts:13-20 (registration)Registration of the getProcedureStep handler within the createHandlers factory function that returns all tool handlers.export function createHandlers(api: ERegulationsApi): ToolHandler[] { return [ createListProceduresHandler(api), createGetProcedureDetailsHandler(api), createGetProcedureStepHandler(api), createSearchProceduresHandler(api), ]; }
- Supporting API method in ERegulationsApi class that fetches the specific procedure step from the backend API endpoint.async getProcedureStep(procedureId: number, stepId: number): Promise<Step> { if (!procedureId || procedureId <= 0) { throw new Error("Procedure ID is required"); } if (!stepId || stepId <= 0) { throw new Error("Step ID is required"); } return this.fetchData<Step>(async () => { logger.log(`Fetching step ${stepId} for procedure ${procedureId}...`); // Access baseUrl at execution time const baseUrl = this.getBaseUrl(); // Use the dedicated step endpoint to get complete step information interface StepResponse { data?: Step; links?: ApiLink[]; } const response = await this.makeRequest<StepResponse>( `${baseUrl}/Procedures/${procedureId}/Steps/${stepId}` ); if (!response || !response.data) { throw new Error( `Failed to get step ${stepId} for procedure ${procedureId}` ); } const stepData = response.data; // Add additional context to the step data return { id: stepId, name: "Unknown", // Default value if step data is incomplete ...(stepData.data || {}), procedureId, _links: stepData.links, }; }); }