Skip to main content
Glama
validate.js1.95 kB
import { Command } from 'commander'; import { join } from 'path'; import { existsSync, readdirSync } from 'fs'; import { pathToFileURL } from 'url'; export const validateCommand = new Command('validate') .description('Validate all tools in the current project') .action(async () => { console.log('🔍 Validating tools...\n'); const distPath = join(process.cwd(), 'dist', 'tools'); if (!existsSync(distPath)) { console.error('❌ No dist/tools directory found. Run "npm run build" first.'); process.exit(1); } const toolFiles = readdirSync(distPath).filter((f) => f.endsWith('.js') && !f.includes('.test.')); const errors = []; let validatedCount = 0; for (const file of toolFiles) { try { const toolPath = pathToFileURL(join(distPath, file)).href; const module = await import(toolPath); const ToolClass = module.default; if (ToolClass && typeof ToolClass === 'function') { const instance = new ToolClass(); if ('validate' in instance && typeof instance.validate === 'function') { try { instance.validate(); validatedCount++; console.log(`✅ ${file}: Valid`); } catch (error) { errors.push(`❌ ${file}: ${error.message}`); } } } } catch (error) { errors.push(`❌ ${file}: Failed to load - ${error.message}`); } } console.log(''); if (errors.length > 0) { console.error('Validation failed:\n'); errors.forEach((error) => console.error(error)); console.error(`\n❌ ${errors.length} error(s) found`); process.exit(1); } else { console.log(`✅ All ${validatedCount} tools validated successfully!`); } });

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/madebyaris/rakitui-ai'

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