Class WebSocketMcpTransport.Builder

java.lang.Object
dev.langchain4j.mcp.client.transport.websocket.WebSocketMcpTransport.Builder
Enclosing class:
WebSocketMcpTransport

public static class WebSocketMcpTransport.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • logResponses

      public WebSocketMcpTransport.Builder logResponses(boolean logResponses)
    • logRequests

      public WebSocketMcpTransport.Builder logRequests(boolean logRequests)
    • url

    • logger

      public WebSocketMcpTransport.Builder logger(org.slf4j.Logger logger)
      Sets a custom Logger to be used for websocket traffic logging. If not specified, a default logger will be used.
      Parameters:
      logger - an alternate Logger to be used instead of the default one provided by Langchain4J for traffic logging.
      Returns:
      this.
    • executor

      public WebSocketMcpTransport.Builder executor(Executor executor)
      An optional Executor that will be used for executing requests and handling responses.
    • timeout

      public WebSocketMcpTransport.Builder timeout(Duration timeout)
      The connection timeout (applied on the websocket client level). Application-level timeouts are handled by the MCP client itself.
    • sslContext

      public WebSocketMcpTransport.Builder sslContext(SSLContext sslContext)
    • headersSupplier

      public WebSocketMcpTransport.Builder headersSupplier(Supplier<Map<String,String>> headersSupplier)
    • headersSupplier

      public WebSocketMcpTransport.Builder headersSupplier(McpHeadersSupplier headersSupplier)
    • maxMessageSize

      public WebSocketMcpTransport.Builder maxMessageSize(Integer maxMessageSize)
      The maximum size, in bytes, of a single message received from the server. When a server sends a larger message, the transport closes the connection with status 1009 (message too big) and all pending requests fail. This protects the client against servers that send an endless or huge message, which would otherwise be buffered in memory until it runs out. The size is that of the JSON text, so binary content such as images, which is base64-encoded, takes about a third more than its raw size. Defaults to 20 MiB.
      Parameters:
      maxMessageSize - the maximum message size in bytes, must be greater than zero; null means the default
      Returns:
      this builder
      Since:
      1.24.0
    • build

      public WebSocketMcpTransport build()