@modelcontextprotocol/sdk
    Preparing search index...

    Function applyMiddlewares

    • Composes multiple fetch middleware functions into a single middleware pipeline. Middleware are applied in the order they appear, creating a chain of handlers.

      Parameters

      • ...middleware: Middleware[]

        Array of fetch middleware to compose into a pipeline

      Returns Middleware

      A single composed middleware function

      // Create a middleware pipeline that handles both OAuth and logging
      const enhancedFetch = applyMiddlewares(
      withOAuth(oauthProvider, 'https://api.example.com'),
      withLogging({ statusLevel: 400 })
      )(fetch);

      // Use the enhanced fetch - it will handle auth and log errors
      const response = await enhancedFetch('https://api.example.com/data');