// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { IncomingMessage } from 'node:http'; import { ClientOptions } from 'sports-odds-api'; import { McpOptions } from './options'; export const parseClientAuthHeaders = (req: IncomingMessage, required?: boolean): Partial => { const apiKeyHeader = Array.isArray(req.headers['x-api-key']) ? req.headers['x-api-key'][0] : req.headers['x-api-key']; const apiKeyParam = Array.isArray(req.headers['x-sports-odds-api-key-header']) ? req.headers['x-sports-odds-api-key-header'][0] : req.headers['x-sports-odds-api-key-header']; return { apiKeyHeader, apiKeyParam }; }; export const getStainlessApiKey = (req: IncomingMessage, mcpOptions: McpOptions): string | undefined => { // Try to get the key from the x-stainless-api-key header const headerKey = Array.isArray(req.headers['x-stainless-api-key']) ? req.headers['x-stainless-api-key'][0] : req.headers['x-stainless-api-key']; if (headerKey && typeof headerKey === 'string') { return headerKey; } // Fall back to value set in the mcpOptions (e.g. from environment variable), if provided return mcpOptions.stainlessApiKey; };