/** * Managed HTTP server for MCP with OAuth 2.1 support. * Provides a complete, ready-to-use HTTP server that handles * OAuth discovery, client registration, and MCP transport. */ import { type Application } from 'express'; import type { Payments } from '../../payments.js'; import type { HttpServerConfig, HttpServerResult } from '../types/http.types.js'; /** * Configuration for the managed MCP server. */ export interface ManagedServerConfig extends HttpServerConfig { /** Payments instance for authentication */ payments: Payments; /** Server version */ version?: string; /** Server description */ description?: string; /** Callback when server starts */ onStart?: (result: HttpServerResult) => void; /** Callback for logging */ onLog?: (message: string, level?: 'info' | 'warn' | 'error') => void; } /** * Start a managed HTTP server with OAuth 2.1 support. * This creates a complete Express server with all OAuth endpoints, * CORS, JSON parsing, and authentication middleware pre-configured. * * @param config - Server configuration * @returns Server result with control methods * * @example * ```typescript * import { Payments } from '@nevermined-io/payments' * * const payments = Payments.getInstance({ * nvmApiKey: process.env.NVM_API_KEY!, * environment: 'staging_sandbox' * }) * * // Start a managed server * const { server, app, stop, baseUrl } = await startManagedServer({ * payments, * port: 5001, * baseUrl: 'http://localhost:5001', * agentId: process.env.NVM_AGENT_ID!, * environment: 'staging_sandbox', * serverName: 'my-mcp-server', * tools: ['hello_world', 'weather'] * }) * * console.log(`Server running at ${baseUrl}`) * * // Later: gracefully stop * await stop() * ``` */ export declare function startManagedServer(config: ManagedServerConfig): Promise; /** * Create an Express application pre-configured with OAuth support, * but without starting the server. This is useful when you want to * add additional routes or middleware before starting. * * @param config - Server configuration (without port/host) * @returns Configured Express application * * @example * ```typescript * const app = createMcpApp({ * payments, * baseUrl: 'http://localhost:5001', * agentId: 'agent_123', * environment: 'staging_sandbox' * }) * * // Add custom routes * app.get('/custom', (req, res) => res.json({ custom: true })) * * // Add MCP handler - auth is handled by withPaywall() on each tool * app.post('/mcp', mcpHandler) * * // Start manually * app.listen(5001) * ``` */ export declare function createMcpApp(config: Omit): Application; //# sourceMappingURL=managed-server.d.ts.map