MCP TypeScript SDK (V2)
    Preparing search index...
    • Creates an Express application pre-configured for MCP servers.

      When the host is '127.0.0.1', 'localhost', or '::1' (the default is '127.0.0.1'), DNS rebinding protection middleware is automatically applied to protect against DNS rebinding attacks on localhost servers.

      Parameters

      Returns Express

      A configured Express application

      const app = createMcpExpressApp();
      
      const appOpen = createMcpExpressApp({ host: '0.0.0.0' }); // No automatic DNS rebinding protection
      const appLocal = createMcpExpressApp({ host: 'localhost' }); // DNS rebinding protection enabled
      const app = createMcpExpressApp({ host: '0.0.0.0', allowedHosts: ['myapp.local', 'localhost'] });