All files / src config.ts

100% Statements 12/12
75% Branches 6/8
100% Functions 0/0
100% Lines 12/12

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                        27x 27x 27x 27x 27x 27x           27x               27x     27x           27x               27x     27x  
/**
 * Centralized configuration for the European Parliament MCP Server.
 *
 * All shared configuration constants and defaults are defined here to ensure
 * consistency across `src/index.ts`, `src/server/cli.ts`, and
 * `src/clients/ep/baseClient.ts`.
 *
 * @module config
 */
 
import { readFileSync, existsSync } from 'fs';
 
const pkgPath = new URL('../package.json', import.meta.url);
let pkg: { version: string } = { version: 'unknown' };
try {
  Eif (existsSync(pkgPath)) {
    const parsed: unknown = JSON.parse(readFileSync(pkgPath, 'utf-8'));
    Eif (
      typeof parsed === 'object' &&
      parsed !== null &&
      'version' in parsed &&
      typeof (parsed as { version: unknown }).version === 'string'
    ) {
      pkg = parsed as { version: string };
    }
  }
} catch {
  // Fall back to { version: 'unknown' } on any read/parse error
}
 
/** Canonical server name used in MCP handshake and CLI output */
export const SERVER_NAME = 'european-parliament-mcp-server';
 
/** Server version loaded from package.json at startup */
export const SERVER_VERSION: string = pkg.version;
 
/**
 * HTTP `User-Agent` header value sent with every request to the EP API.
 * Includes the actual package version instead of a hardcoded string.
 */
export const USER_AGENT = `European-Parliament-MCP-Server/${pkg.version}`;
 
/**
 * Default rate limit applied to EP API requests (requests per minute).
 * Consumed by `baseClient.ts` (`DEFAULT_RATE_LIMIT_TOKENS`) and by the CLI
 * health/help output so that the displayed default always matches the
 * enforced default.
 */
export const DEFAULT_RATE_LIMIT_PER_MINUTE = 100;
 
/** Default base URL for the European Parliament Open Data Portal API v2 */
export const DEFAULT_API_URL = 'https://data.europarl.europa.eu/api/v2/';