Skip to main content
Glama
validation.ts1.74 kB
import { CONFIG, REQUIRED_ENV_VARS } from '../config/config.js'; export interface ValidationResult { isValid: boolean; errors: string[]; warnings: string[]; } /** * Validates the environment configuration * Following CIQ's Excellence principle - validate thoroughly before proceeding */ export function validateEnvironment(): ValidationResult { const errors: string[] = []; const warnings: string[] = []; // Check required environment variables for (const envVar of REQUIRED_ENV_VARS) { const value = process.env[envVar]; if (!value || value.trim() === '') { errors.push(`Missing required environment variable: ${envVar}`); } } // Validate API key format (basic check) if (CONFIG.apiKey && !CONFIG.apiKey.match(/^[a-zA-Z0-9_-]+$/)) { warnings.push('API key format may be invalid - should contain only alphanumeric characters, dashes, and underscores'); } // Validate timeout values if (CONFIG.timeout < 1000) { warnings.push('Timeout value is very low (< 1000ms) - may cause frequent timeouts'); } if (CONFIG.timeout > 300000) { warnings.push('Timeout value is very high (> 300000ms) - may cause long waits'); } // Validate rate limiting values if (CONFIG.rateLimit.requestsPerMinute > 300) { warnings.push('Rate limit is set very high - may exceed Canny API limits'); } return { isValid: errors.length === 0, errors, warnings, }; } /** * Validates input parameters for tools */ export function validateToolInput<T>(input: unknown, schema: any): T { try { return schema.parse(input) as T; } catch (error) { throw new Error(`Invalid input parameters: ${error instanceof Error ? error.message : 'Unknown validation error'}`); } }

Latest Blog Posts

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/itsocialist/canny-mcp-server'

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