UNPKG

@agentauth/mcp

Version:

A universal proxy for remote MCP server connections, with and without authentication.

53 lines 2.46 kB
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'; export type TransportStrategy = 'sse-only' | 'http-only' | 'sse-first' | 'http-first'; export declare const pid: number; export declare let DEBUG: boolean; /** * Gets current timestamp in ISO format */ export declare function timestamp(): string; /** * Logs a message with timestamp and process ID */ export declare function log(str: string, ...rest: unknown[]): void; /** * Logs debug messages when debug mode is enabled */ export declare function debugLog(str: string, ...rest: unknown[]): void; /** * Enables or disables debug logging */ export declare function setDebug(val: boolean): void; /** * Validates that the server URL uses HTTPS or is allowed via exceptions * @param serverUrl The URL to validate * @param allowHttp Whether HTTP is explicitly allowed via --allow-http flag * @throws Error if URL is not secure and not allowed */ export declare function validateServerUrlSecurity(serverUrl: string, allowHttp: boolean): void; /** * Generates fresh AgentAuth headers for each request with current timestamp * @param token The AgentAuth token to sign with * @returns Headers object with address, signature, and base64-encoded payload */ export declare function generateFreshAuthHeaders(token: string): Record<string, string>; /** * Creates a bidirectional proxy between two transports * @param params The transport connections to proxy between */ export declare function mcpProxy({ transportToClient, transportToServer }: { transportToClient: Transport; transportToServer: Transport; }): void; /** * Creates and connects to a remote server with transport strategy fallback support. * Uses the AuthRefreshTransportWrapper to provide fresh auth headers when token is provided. * @param serverUrl The URL of the remote server * @param strategy The transport strategy to use (http-first, sse-first, etc.) * @param recursionReasons Set tracking fallback attempts to prevent infinite recursion * @param token Optional AgentAuth token for authentication * @param customHeaders Optional custom headers to include with requests * @returns The connected transport, wrapped with auth refresh if token provided */ export declare function connectToRemoteServer(serverUrl: string, strategy?: TransportStrategy, recursionReasons?: Set<string>, token?: string, customHeaders?: Record<string, string>): Promise<Transport>; //# sourceMappingURL=utils.d.ts.map