UNPKG

clinicaltrialsgov-mcp-server

Version:

ClinicalTrials.gov Model Context Protocol (MCP) Server that provides a suite of tools for interacting with the official ClinicalTrials.gov v2 API. Enables AI agents and LLMs to programmatically search, retrieve, and analyze clinical trial data.

118 lines (117 loc) 5.75 kB
/** * @fileoverview Loads, validates, and exports application configuration. * This module centralizes configuration management, sourcing values from * environment variables and `package.json`. It uses Zod for schema validation * to ensure type safety and correctness of configuration parameters. * * Key responsibilities: * - Load environment variables from a `.env` file. * - Read `package.json` for default server name and version. * - Define a Zod schema for all expected environment variables. * - Validate environment variables against the schema. * - Construct and export a comprehensive `config` object. * - Export individual configuration values like `logLevel` and `environment` for convenience. * * @module src/config/index */ /** * Main application configuration object. * Aggregates settings from validated environment variables and `package.json`. */ export declare const config: { /** Information from package.json. */ pkg: { name: string; version: string; }; /** MCP server name. Env `MCP_SERVER_NAME` > `package.json` name > "mcp-ts-template". */ mcpServerName: string; /** MCP server version. Env `MCP_SERVER_VERSION` > `package.json` version > "0.0.0". */ mcpServerVersion: string; /** Logging level. From `MCP_LOG_LEVEL` env var. Default: "debug". */ logLevel: string; /** Absolute path to the logs directory. From `LOGS_DIR` env var. */ logsPath: string | null; /** Runtime environment. From `NODE_ENV` env var. Default: "development". */ environment: string; /** MCP transport type ('stdio' or 'http'). From `MCP_TRANSPORT_TYPE` env var. Default: "stdio". */ mcpTransportType: "stdio" | "http"; /** MCP session mode ('stateless', 'stateful', 'auto'). From `MCP_SESSION_MODE` env var. Default: "auto". */ mcpSessionMode: "stateless" | "stateful" | "auto"; /** HTTP server port (if http transport). From `MCP_HTTP_PORT` env var. Default: 3010. */ /** HTTP server port (if http transport). From `MCP_HTTP_PORT` env var. Default: 3010. */ mcpHttpPort: number; /** HTTP server host (if http transport). From `MCP_HTTP_HOST` env var. Default: "127.0.0.1". */ mcpHttpHost: string; /** MCP endpoint path for HTTP transport. From `MCP_HTTP_ENDPOINT_PATH`. Default: "/mcp". */ mcpHttpEndpointPath: string; /** Max retries for port binding. From `MCP_HTTP_MAX_PORT_RETRIES`. Default: 15. */ mcpHttpMaxPortRetries: number; /** Delay between port binding retries. From `MCP_HTTP_PORT_RETRY_DELAY_MS`. Default: 50. */ mcpHttpPortRetryDelayMs: number; /** Timeout for stale stateful sessions. From `MCP_STATEFUL_SESSION_STALE_TIMEOUT_MS`. Default: 1800000. */ mcpStatefulSessionStaleTimeoutMs: number; /** Array of allowed CORS origins (http transport). From `MCP_ALLOWED_ORIGINS` (comma-separated). */ mcpAllowedOrigins: string[] | undefined; /** Auth secret key (JWTs, http transport). From `MCP_AUTH_SECRET_KEY`. CRITICAL. */ mcpAuthSecretKey: string | undefined; /** The authentication mode ('jwt' or 'oauth'). From `MCP_AUTH_MODE`. */ mcpAuthMode: "jwt" | "oauth" | "none"; /** OAuth 2.1 Issuer URL. From `OAUTH_ISSUER_URL`. */ oauthIssuerUrl: string | undefined; /** OAuth 2.1 JWKS URI. From `OAUTH_JWKS_URI`. */ oauthJwksUri: string | undefined; /** OAuth 2.1 Audience. From `OAUTH_AUDIENCE`. */ oauthAudience: string | undefined; /** Development mode client ID. From `DEV_MCP_CLIENT_ID`. */ devMcpClientId: string | undefined; /** Development mode scopes. From `DEV_MCP_SCOPES`. */ devMcpScopes: string[] | undefined; /** OpenRouter App URL. From `OPENROUTER_APP_URL`. Default: "http://localhost:3000". */ openrouterAppUrl: string; /** OpenRouter App Name. From `OPENROUTER_APP_NAME`. Defaults to `mcpServerName`. */ openrouterAppName: string; /** OpenRouter API Key. From `OPENROUTER_API_KEY`. */ openrouterApiKey: string | undefined; /** Default LLM model. From `LLM_DEFAULT_MODEL`. */ llmDefaultModel: string; /** Default LLM temperature. From `LLM_DEFAULT_TEMPERATURE`. */ llmDefaultTemperature: number | undefined; /** Default LLM top_p. From `LLM_DEFAULT_TOP_P`. */ llmDefaultTopP: number | undefined; /** Default LLM max tokens. From `LLM_DEFAULT_MAX_TOKENS`. */ llmDefaultMaxTokens: number | undefined; /** Default LLM top_k. From `LLM_DEFAULT_TOP_K`. */ llmDefaultTopK: number | undefined; /** Default LLM min_p. From `LLM_DEFAULT_MIN_P`. */ llmDefaultMinP: number | undefined; /** OAuth Proxy configurations. Undefined if no related env vars are set. */ oauthProxy: { authorizationUrl: string | undefined; tokenUrl: string | undefined; revocationUrl: string | undefined; issuerUrl: string | undefined; serviceDocumentationUrl: string | undefined; defaultClientRedirectUris: string[] | undefined; } | undefined; /** Supabase configuration. Undefined if no related env vars are set. */ supabase: { url: string; anonKey: string; serviceRoleKey: string | undefined; } | undefined; /** Absolute path to the ClinicalTrials.gov data directory. From `CLINICALTRIALS_DATA_PATH` env var. */ clinicalTrialsDataPath: string | null; /** Maximum number of studies to fetch for analysis. From `MAX_STUDIES_FOR_ANALYSIS` env var. */ maxStudiesForAnalysis: number; }; /** * Configured logging level for the application. * Exported for convenience. */ export declare const logLevel: string; /** * Configured runtime environment ("development", "production", etc.). * Exported for convenience. */ export declare const environment: string;