Skip to main content
Glama

MCP API Server

by fikri2992
validation.ts874 B
import { z } from 'zod'; export class ValidationError extends Error { constructor(message: string, public parameter?: string) { super(message); this.name = 'ValidationError'; } } export function isValidationError(error: any): error is ValidationError { return error instanceof ValidationError; } export function formatValidationError(error: ValidationError): string { return error.parameter ? `Validation failed for parameter '${error.parameter}': ${error.message}` : `Validation failed: ${error.message}`; } export function validateRequest<T>(validator: (params: any) => T, params: any): T { try { return validator(params); } catch (error) { if (error instanceof ValidationError) { throw error; } throw new ValidationError(`Validation failed: ${error instanceof Error ? error.message : 'Unknown 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/fikri2992/mcp0'

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