/**
 * @license
 * Copyright 2025 ReverseCraft
 * SPDX-License-Identifier: Apache-2.0
 */
/**
 * Parse an integer from environment variable with a default fallback.
 */
function parseEnvInt(envVar, defaultValue) {
    if (!envVar)
        return defaultValue;
    const parsed = parseInt(envVar, 10);
    return Number.isNaN(parsed) || parsed <= 0 ? defaultValue : parsed;
}
/**
 * Parse a boolean from environment variable with a default fallback.
 */
function parseEnvBool(envVar, defaultValue) {
    if (!envVar)
        return defaultValue;
    return envVar.toLowerCase() === 'true';
}
/**
 * Get the current MCP configuration from environment variables.
 * Environment variables:
 * - MCP_MAX_BODY_SIZE: Max response/request body size (default: 10000)
 * - MCP_DEFAULT_PAGE_SIZE: Default pagination size (default: 20)
 * - MCP_MAX_SNIPPET_LENGTH: Max snippet length for search results (default: 200)
 * - MCP_MAX_PROPERTIES: Max properties for debugger (default: 20)
 * - MCP_MAX_INLINE_STRING_LENGTH: Max string length inline in debugger (default: 200)
 * - MCP_MAX_URL_LENGTH: Max URL length in request lists (default: 150)
 * - MCP_DEBUGGER_MAX_PROPERTIES_PER_SCOPE: Max properties per scope in debugger status (default: 10)
 * - MCP_DEBUGGER_SKIP_SCOPE_VARIABLES: Skip scope variable inspection (default: false)
 * - MCP_DEBUGGER_USE_OBJECT_PREVIEWS: Use object previews instead of full retrieval (default: true)
 * - MCP_DEBUGGER_MAX_OBJECT_DEPTH: Max depth for nested object inspection (default: 1)
 */
export function getConfig() {
    return {
        maxBodySize: parseEnvInt(process.env.MCP_MAX_BODY_SIZE, 10000),
        defaultPageSize: parseEnvInt(process.env.MCP_DEFAULT_PAGE_SIZE, 20),
        maxSnippetLength: parseEnvInt(process.env.MCP_MAX_SNIPPET_LENGTH, 200),
        maxProperties: parseEnvInt(process.env.MCP_MAX_PROPERTIES, 20),
        maxInlineStringLength: parseEnvInt(process.env.MCP_MAX_INLINE_STRING_LENGTH, 200),
        maxUrlLength: parseEnvInt(process.env.MCP_MAX_URL_LENGTH, 150),
        debugger: {
            maxPropertiesPerScope: parseEnvInt(process.env.MCP_DEBUGGER_MAX_PROPERTIES_PER_SCOPE, 10),
            skipScopeVariables: parseEnvBool(process.env.MCP_DEBUGGER_SKIP_SCOPE_VARIABLES, false),
            useObjectPreviews: parseEnvBool(process.env.MCP_DEBUGGER_USE_OBJECT_PREVIEWS, true),
            maxObjectDepth: parseEnvInt(process.env.MCP_DEBUGGER_MAX_OBJECT_DEPTH, 1),
        },
    };
}
//# sourceMappingURL=config.js.map