Skip to main content
Glama
config.ts1.94 kB
import dotenv from 'dotenv'; dotenv.config(); export interface Config { simplifierBaseUrl: string; simplifierToken?: string | undefined; credentialsFile?: string | undefined; skipConnectionTest: boolean; httpRequestLogFile?: string | undefined; } // Config without sensitive data export interface DisplayConfig { baseUrl: string; skipConnectionTest: boolean; httpRequestLogFile?: string | undefined; } export function validateConfig(): Config { const simplifierBaseUrl = process.env.SIMPLIFIER_BASE_URL; if (!simplifierBaseUrl) { throw new Error('SIMPLIFIER_BASE_URL environment variable is required'); } try { // Basic URL validation new URL(simplifierBaseUrl); } catch (error) { throw new Error('SIMPLIFIER_BASE_URL must be a valid URL'); } if (!process.env.SIMPLIFIER_TOKEN && !process.env.SIMPLIFIER_CREDENTIALS_FILE) { throw new Error('Either variable SIMPLIFIER_TOKEN with an actual token or SIMPLIFIER_CREDENTIALS_FILE pointing to a valid credentials file must be set!'); } if (process.env.SIMPLIFIER_TOKEN && process.env.SIMPLIFIER_CREDENTIALS_FILE) { throw new Error('Cannot set both SIMPLIFIER_TOKEN and SIMPLIFIER_CREDENTIALS_FILE. Please use only one authentication method.'); } return { simplifierBaseUrl, simplifierToken: process.env.SIMPLIFIER_TOKEN, credentialsFile: process.env.SIMPLIFIER_CREDENTIALS_FILE, skipConnectionTest: process.env.SIMPLIFIER_SKIP_CONNECTION_TEST ? process.env.SIMPLIFIER_SKIP_CONNECTION_TEST !== "false" : false, httpRequestLogFile: process.env.HTTP_REQUEST_LOG_FILE, }; } /** * Returns the configuration, including just the base URL for display purposes */ export function getConfig(): DisplayConfig { return { baseUrl: config.simplifierBaseUrl, skipConnectionTest: config.skipConnectionTest, httpRequestLogFile: config.httpRequestLogFile, }; } export const config = validateConfig();

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/SimplifierIO/simplifier-mcp'

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