mcp-use
Version:
Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.
69 lines • 1.94 kB
TypeScript
/**
* OAuth Proxy Routes
*
* Provides CORS-free OAuth flow for browser clients by proxying OAuth requests.
*
* This middleware handles:
* - OAuth metadata discovery (/.well-known/ endpoints)
* - Token exchange requests (/token endpoints)
* - Dynamic client registration (/register endpoints)
* - Authorization requests (/authorize endpoints)
*
* @module oauth-proxy
*/
import type { Context, Hono } from "hono";
/**
* Options for configuring the OAuth proxy
*/
export interface OAuthProxyOptions {
/**
* Base path for OAuth proxy routes
* @default "/oauth"
*/
basePath?: string;
/**
* Enable request logging
* @default true
*/
enableLogging?: boolean;
/**
* Optional authentication function to validate requests
* Return true to allow the request, false to reject with 401
*/
authenticate?: (c: Context) => Promise<boolean> | boolean;
/**
* Optional validator to check if target URL is allowed
* Return true to allow, false to reject with 403
*/
validateTarget?: (targetUrl: string, c: Context) => Promise<boolean> | boolean;
}
/**
* Mount OAuth proxy routes on a Hono app
*
* This creates endpoints for proxying OAuth requests to bypass CORS restrictions.
*
* Creates the following routes:
* - POST /oauth/proxy - General OAuth request proxy
* - GET /oauth/metadata - OAuth metadata discovery proxy
*
* @param app - Hono application instance
* @param options - Configuration options for the proxy
*
* @example
* ```typescript
* import { Hono } from "hono";
* import { mountOAuthProxy } from "mcp-use/server";
*
* const app = new Hono();
*
* // Basic usage
* mountOAuthProxy(app);
*
* // With custom path
* mountOAuthProxy(app, {
* basePath: "/inspector/api/oauth"
* });
* ```
*/
export declare function mountOAuthProxy(app: Hono, options?: OAuthProxyOptions): void;
//# sourceMappingURL=proxy.d.ts.map