@modelcontextprotocol/sdk
    Preparing search index...

    Function withLogging

    • Creates a fetch middleware that logs HTTP requests and responses.

      When called without arguments withLogging(), it uses the default logger that:

      • Logs successful requests (2xx) to console.log
      • Logs error responses (4xx/5xx) and network errors to console.error
      • Logs all requests regardless of status (statusLevel: 0)
      • Does not include request or response headers in logs
      • Measures and displays request duration in milliseconds

      Important: the default logger uses both console.log and console.error so it should not be used with stdio transports and applications.

      Parameters

      Returns Middleware

      A fetch middleware function