express.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { Express } from 'express';
  2. /**
  3. * Options for creating an MCP Express application.
  4. */
  5. export interface CreateMcpExpressAppOptions {
  6. /**
  7. * The hostname to bind to. Defaults to '127.0.0.1'.
  8. * When set to '127.0.0.1', 'localhost', or '::1', DNS rebinding protection is automatically enabled.
  9. */
  10. host?: string;
  11. /**
  12. * List of allowed hostnames for DNS rebinding protection.
  13. * If provided, host header validation will be applied using this list.
  14. * For IPv6, provide addresses with brackets (e.g., '[::1]').
  15. *
  16. * This is useful when binding to '0.0.0.0' or '::' but still wanting
  17. * to restrict which hostnames are allowed.
  18. */
  19. allowedHosts?: string[];
  20. }
  21. /**
  22. * Creates an Express application pre-configured for MCP servers.
  23. *
  24. * When the host is '127.0.0.1', 'localhost', or '::1' (the default is '127.0.0.1'),
  25. * DNS rebinding protection middleware is automatically applied to protect against
  26. * DNS rebinding attacks on localhost servers.
  27. *
  28. * @param options - Configuration options
  29. * @returns A configured Express application
  30. *
  31. * @example
  32. * ```typescript
  33. * // Basic usage - defaults to 127.0.0.1 with DNS rebinding protection
  34. * const app = createMcpExpressApp();
  35. *
  36. * // Custom host - DNS rebinding protection only applied for localhost hosts
  37. * const app = createMcpExpressApp({ host: '0.0.0.0' }); // No automatic DNS rebinding protection
  38. * const app = createMcpExpressApp({ host: 'localhost' }); // DNS rebinding protection enabled
  39. *
  40. * // Custom allowed hosts for non-localhost binding
  41. * const app = createMcpExpressApp({ host: '0.0.0.0', allowedHosts: ['myapp.local', 'localhost'] });
  42. * ```
  43. */
  44. export declare function createMcpExpressApp(options?: CreateMcpExpressAppOptions): Express;
  45. //# sourceMappingURL=express.d.ts.map