Skip to main content
Glama
config-loader.ts1.79 kB
/** * Configuration Loader Utility * Loads and validates environment configuration from JSON files */ import * as fs from 'fs'; import * as path from 'path'; import { EnvironmentConfig } from '../types/index.js'; export class ConfigLoader { private static readonly DEFAULT_CONFIG_PATH = path.join(__dirname, '../../config/environments.json'); /** * Load environment configuration from file */ static loadConfig(configPath?: string): EnvironmentConfig { const filePath = configPath || this.DEFAULT_CONFIG_PATH; try { const configData = fs.readFileSync(filePath, 'utf8'); const config = JSON.parse(configData) as EnvironmentConfig; this.validateConfig(config); return config; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to load configuration from ${filePath}: ${error.message}`); } throw error; } } /** * Validate configuration structure */ private static validateConfig(config: EnvironmentConfig): void { if (!config.mappings || !Array.isArray(config.mappings)) { throw new Error('Configuration must have a mappings array'); } for (const mapping of config.mappings) { if (!mapping.directory || !mapping.config) { throw new Error('Each mapping must have directory and config properties'); } if (!mapping.config.organizationUrl || !mapping.config.pat || !mapping.config.project) { throw new Error('Each config must have organizationUrl, pat, and project properties'); } } } /** * Check if configuration file exists */ static configExists(configPath?: string): boolean { const filePath = configPath || this.DEFAULT_CONFIG_PATH; return fs.existsSync(filePath); } }

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/wangkanai/devops-enhanced-mcp'

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