UNPKG

openrouter-image-mcp

Version:

MCP server for image analysis using OpenRouter's vision models

42 lines (41 loc) 1.5 kB
import { config as loadEnv } from 'dotenv'; export class Config { static instance; openRouterConfig; serverConfig; constructor() { // Load environment variables from .env file (for local development only) // In production (MCP usage), env vars are passed by the MCP client via the config // If .env doesn't exist, dotenv will silently skip it - that's expected loadEnv(); this.validateEnvironment(); this.openRouterConfig = { apiKey: process.env.OPENROUTER_API_KEY, model: process.env.OPENROUTER_MODEL || 'anthropic/claude-3.5-sonnet', baseUrl: process.env.OPENROUTER_BASE_URL || 'https://openrouter.ai/api/v1', }; this.serverConfig = { port: parseInt(process.env.PORT || '3000'), logLevel: process.env.LOG_LEVEL || 'info', retryAttempts: parseInt(process.env.RETRY_ATTEMPTS || '3'), maxImageSize: parseInt(process.env.MAX_IMAGE_SIZE || '10485760'), // 10MB }; } static getInstance() { if (!Config.instance) { Config.instance = new Config(); } return Config.instance; } validateEnvironment() { if (!process.env.OPENROUTER_API_KEY) { throw new Error('OPENROUTER_API_KEY environment variable is required'); } } getOpenRouterConfig() { return this.openRouterConfig; } getServerConfig() { return this.serverConfig; } }