import { Express } from 'express'; import { McpAuthConfig } from './types.js'; import { requireScopes } from './middleware.js'; export type { McpAuthConfig } from './types.js'; /** * Server Integration Utilities * * Easy integration of OAuth 2.1 auth into MCP servers */ /** * Configure authentication for MCP server * * This adds: * 1. Protected Resource Metadata endpoint * 2. Authentication middleware to specified routes * * @param app - Express application * @param config - Auth configuration * @param protectRoutes - Routes to protect with auth (default: all /mcp routes) * * @example * ```typescript * const app = express(); * * configureServerAuth(app, { * resourceUri: 'https://mcp.example.com', * authorizationServers: ['https://auth.example.com'], * tokenIntrospectionEndpoint: 'https://auth.example.com/oauth/introspect', * tokenIntrospectionClientId: 'mcp-server', * tokenIntrospectionClientSecret: process.env.INTROSPECTION_SECRET, * audience: 'https://mcp.example.com', * scopesSupported: ['mcp:read', 'mcp:write'] * }, { * protectRoutes: ['/mcp/*'] * }); * ``` */ export declare function configureServerAuth(app: Express, config: McpAuthConfig, options?: { protectRoutes?: string[]; metadataPath?: string; }): void; /** * Scope-based route protection helper * * @example * ```typescript * const scopes = createScopeGuards(['mcp:read', 'mcp:write', 'mcp:admin']); * * app.get('/mcp/tools', scopes.read, (req, res) => { * // List tools - requires mcp:read * }); * * app.post('/mcp/tools/execute', scopes.write, (req, res) => { * // Execute tool - requires mcp:write * }); * * app.delete('/mcp/resources', scopes.admin, (req, res) => { * // Delete resource - requires mcp:admin * }); * ``` */ export declare function createScopeGuards(scopeConfig: { read?: string[]; write?: string[]; admin?: string[]; [key: string]: string[] | undefined; }): Record>; /** * Create standard MCP scope configuration * * Returns scope guards for common MCP operations: * - read: List tools, resources, prompts * - execute: Execute tools, get prompts * - write: Modify resources * - admin: Server configuration * * @param scopePrefix - Scope prefix (default: 'mcp') */ export declare function createMCPScopeGuards(scopePrefix?: string): Record>>; /** * Generate suggested scopes for MCP server * * Returns standard scope definitions for MCP operations */ export declare function getStandardMCPScopes(scopePrefix?: string): { scopes: string[]; descriptions: Record; }; /** * Helper to validate auth configuration */ export declare function validateAuthConfig(config: McpAuthConfig): { valid: boolean; errors: string[]; warnings: string[]; }; //# sourceMappingURL=server-integration.d.ts.map