Skip to main content
Glama

eRegulations MCP Server

by unctad-ai
get-procedure-step.ts1.89 kB
import { zodToJsonSchema } from "zod-to-json-schema"; import { ERegulationsApi } from "../../../services/eregulations-api.js"; import { formatters } from "../formatters/index.js"; import type { ToolHandler } from "./types.js"; import { GetProcedureStepSchema, ToolName } from "../schemas.js"; import { logger } from "../../../utils/logger.js"; import { z } from "zod"; // Define the specific type for args based on the schema type GetProcedureStepArgs = z.infer<typeof GetProcedureStepSchema>; 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) }`, }, ], }; } }, }; }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/unctad-ai/eregulations-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server