All files / scripts/mcp-client/config defaults.ts

100% Statements 5/5
100% Branches 4/4
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30                        38x 38x           38x             132x 132x    
/**
 * @module mcp-client/config/defaults
 * @description Default timeout, retry, and server URL constants for the
 * MCPClient. Resolution is centralised here so a single edit changes the
 * timeout/retry behaviour for all riksdag-regering callers.
 *
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import { getDefaultMcpServerUrl } from './gateway-resolver.js';
 
export const DEFAULT_MAX_RETRIES = 3;
export const RETRY_DELAY = 2000;
 
/**
 * Server URL snapshot resolved once at module load. Mirrors the legacy
 * `DEFAULT_MCP_SERVER_URL` constant from the monolithic client.
 */
export const DEFAULT_MCP_SERVER_URL: string = getDefaultMcpServerUrl();
 
/**
 * Resolve the per-request timeout (ms) from `MCP_CLIENT_TIMEOUT_MS` env var.
 * Falls back to 30 s. Invalid values fall back to 30 s as well.
 */
export function getDefaultTimeout(): number {
  const envVal = process.env['MCP_CLIENT_TIMEOUT_MS'];
  return envVal ? (Number.parseInt(envVal, 10) || 30_000) : 30_000;
}