UNPKG

mcp-framework

Version:

Framework for building Model Context Protocol (MCP) servers in Typescript

38 lines (37 loc) 931 B
import { IncomingMessage } from "node:http"; import { AuthProvider, AuthResult } from "../types.js"; export declare const DEFAULT_API_KEY_HEADER_NAME = "X-API-Key"; /** * Configuration options for API key authentication */ export interface APIKeyConfig { /** * Valid API keys */ keys: string[]; /** * Name of the header containing the API key * @default "X-API-Key" */ headerName?: string; } /** * API key-based authentication provider */ export declare class APIKeyAuthProvider implements AuthProvider { private config; constructor(config: APIKeyConfig); /** * Get the number of configured API keys */ getKeyCount(): number; /** * Get the configured header name */ getHeaderName(): string; authenticate(req: IncomingMessage): Promise<boolean | AuthResult>; getAuthError(): { message: string; status: number; }; }