lokalise-mcp
Version:
The Lokalise MCP Server brings Lokalise's localization power to Claude and AI assistants—manage projects, keys, and translations by chat.
144 lines (143 loc) • 4.85 kB
TypeScript
import { type RuntimeConfig, type TransportMode } from "../schemas/config.schema.js";
import type { ConfigValidationResult, DebugConfig, IConfigLoader, NodeEnv } from "../types/config.types.js";
/**
* Configuration loader that handles multiple sources with priority:
* 1. HTTP query config (from Smithery query parameters)
* 2. MCP initialization config (from clientInfo)
* 3. Direct ENV pass (process.env)
* 4. .env file in project root
* 5. Global config file at $HOME/.mcp/configs.json
*
* This is the SINGLE ENTRY POINT for all configuration access in the application.
* All files and modules should read environment variables through this utility,
* not directly from process.env. All configuration access is strongly typed through Zod schemas.
*
* @example
* import { config } from "./shared/utils/config.util.js";
*
* // Get typed configuration values
* const apiKey = config.getLokaliseApiKey();
* const transportMode = config.getTransportMode();
* const isDebug = config.isDebugEnabled();
*/
declare class ConfigLoader implements IConfigLoader {
private packageName;
private configLoaded;
private mcpInitConfig;
private httpQueryConfig;
private smitheryConfig;
private mergedConfig;
/**
* Create a new ConfigLoader instance
* @param packageName The package name to use for global config lookup
*/
constructor(packageName: string);
/**
* Set configuration from Smithery base64-encoded config parameter (highest priority)
* @param configBase64 Base64-encoded JSON configuration string
*/
setSmitheryConfig(configBase64: string): void;
/**
* Set configuration from HTTP query parameters (second highest priority)
* @param config Configuration object from HTTP query parameters
*/
setHttpQueryConfig(config: Record<string, unknown>): void;
/**
* Set configuration from MCP initialization (second highest priority)
* @param config Configuration object from MCP clientInfo
*/
setMcpInitConfig(config: Record<string, unknown>): void;
/**
* Load configuration from all sources with proper priority
*/
load(): void;
/**
* Force reload configuration from all sources.
* This is useful when configuration changes at runtime (e.g., from HTTP query params).
*/
reload(): void;
/**
* Load configuration from .env file in project root
*/
private loadFromEnvFile;
/**
* Load configuration from global config file at $HOME/.mcp/configs.json
*/
private loadFromGlobalConfig;
/**
* Merge configurations from all sources according to priority
*/
private mergeConfigurations;
/**
* Get a configuration value
* @param key The configuration key
* @param defaultValue The default value if the key is not found
* @returns The configuration value or the default value
*/
get(key: string, defaultValue?: string): string | undefined;
/**
* Get a boolean configuration value
* @param key The configuration key
* @param defaultValue The default value if the key is not found
* @returns The boolean configuration value or the default value
*/
getBoolean(key: string, defaultValue?: boolean): boolean;
/**
* Get the Lokalise API key (required)
* @throws ConfigurationError if not set
*/
getLokaliseApiKey(): string;
/**
* Get the Lokalise API hostname with default
*/
getLokaliseApiHostname(): string;
/**
* Get the transport mode
*/
getTransportMode(): TransportMode;
/**
* Get the server port
*/
getPort(): number;
/**
* Get debug configuration (can be boolean or pattern string)
*/
getDebugConfig(): DebugConfig;
/**
* Check if debug is enabled
*/
isDebugEnabled(): boolean;
/**
* Get debug pattern if debug is a string pattern
*/
getDebugPattern(): string | undefined;
/**
* Check if running in test environment
*/
isTestEnvironment(): boolean;
/**
* Check if running in MCP server mode
*/
isMcpServerMode(): boolean;
/**
* Get the Node environment
*/
getNodeEnv(): NodeEnv | undefined;
/**
* Validate the current configuration
*/
validate(): ConfigValidationResult;
/**
* Get the full validated configuration object
*/
getFullConfig(): RuntimeConfig;
/**
* Get the Lokalise hostname from the configuration (legacy method)
* @param defaultValue The default value if the key is not found
* @returns The Lokalise hostname or the default value
* @deprecated Use getLokaliseApiHostname() instead
*/
getLokaliseHostname(defaultValue?: string): string | undefined;
}
export declare const config: ConfigLoader;
export {};