import dotenv from 'dotenv'; // Load environment variables from .env file dotenv.config(); /** * Environment configuration interface */ export interface EnvConfig { /** * MCP server URL * @default 'http://localhost:3000' */ mcpServerUrl: string; /** * AWS region to use * @default 'us-east-1' */ awsRegion: string; /** * Connection timeout in milliseconds * @default 10000 */ connectionTimeout: number; /** * Log level (debug, info, warn, error) * @default 'info' */ logLevel: 'debug' | 'info' | 'warn' | 'error'; } /** * Default configuration values */ const DEFAULT_CONFIG: EnvConfig = { mcpServerUrl: 'http://localhost:3000', awsRegion: 'us-east-1', connectionTimeout: 10000, logLevel: 'info', }; /** * Load environment configuration with defaults * @returns Configuration with defaults applied */ export function loadEnvConfig(): EnvConfig { return { mcpServerUrl: process.env.MCP_SERVER_URL || DEFAULT_CONFIG.mcpServerUrl, awsRegion: process.env.AWS_REGION || DEFAULT_CONFIG.awsRegion, connectionTimeout: process.env.CONNECTION_TIMEOUT ? parseInt(process.env.CONNECTION_TIMEOUT, 10) : DEFAULT_CONFIG.connectionTimeout, logLevel: (process.env.LOG_LEVEL as EnvConfig['logLevel']) || DEFAULT_CONFIG.logLevel, }; } /** * Get AWS credential status from environment variables * @returns Object describing AWS credential availability */ export function getAwsCredentialStatus(): Record { return { AWS_REGION: process.env.AWS_REGION ? 'Set' : 'Not set', AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID ? `Set (${process.env.AWS_ACCESS_KEY_ID.substring(0, 4)}...)` : 'Not set', AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY ? `Set (${process.env.AWS_SECRET_ACCESS_KEY.length} chars)` : 'Not set', AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN ? `Set (${process.env.AWS_SESSION_TOKEN.length} chars)` : 'Not set', AWS_PROFILE: process.env.AWS_PROFILE ? 'Set' : 'Not set', }; }