UNPKG

mcp-framework

Version:

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

40 lines (39 loc) 982 B
import { IncomingMessage } from "node:http"; import { Algorithm } from "jsonwebtoken"; import { AuthProvider, AuthResult } from "../types.js"; /** * Configuration options for JWT authentication */ export interface JWTConfig { /** * Secret key for verifying JWT tokens */ secret: string; /** * Allowed JWT algorithms * @default ["HS256"] */ algorithms?: Algorithm[]; /** * Name of the header containing the JWT token * @default "Authorization" */ headerName?: string; /** * Whether to require "Bearer" prefix in Authorization header * @default true */ requireBearer?: boolean; } /** * JWT-based authentication provider */ export declare class JWTAuthProvider implements AuthProvider { private config; constructor(config: JWTConfig); authenticate(req: IncomingMessage): Promise<boolean | AuthResult>; getAuthError(): { message: string; status: number; }; }