Class StreamableHttpMcpTransport.Builder
java.lang.Object
dev.langchain4j.mcp.client.transport.http.StreamableHttpMcpTransport.Builder
- Enclosing class:
StreamableHttpMcpTransport
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()customHeaders(McpHeadersSupplier customHeadersSupplier) A supplier for dynamic request headers of the MCP server.customHeaders(Supplier<Map<String, String>> customHeadersSupplier) A supplier for dynamic request headers of the MCP server.customHeaders(Map<String, String> customHeaders) The request headers of the MCP server.An optionalExecutorthat will be used for executing requests and handling responses.logger(org.slf4j.Logger logger) Sets a customLoggerto be used for traffic logging (both requests and responses).logRequests(boolean logRequests) Whether to log all requests that are sent over this transport.logResponses(boolean logResponses) Whether to log all responses received over this transport.Forces the transport to use HTTP/1.1 instead of the default HTTP/2.sslContext(SSLContext sslContext) Supplies a customSSLContextused when establishing HTTPS connections to the MCP server, allowing private CAs or certificates.subsidiaryChannel(boolean subsidiaryChannelEnabled) Enables or disables the subsidiary SSE channel.The connection timeout (applied on the http client level).The URL of the MCP server.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
url
The URL of the MCP server. -
customHeaders
The request headers of the MCP server. -
customHeaders
public StreamableHttpMcpTransport.Builder customHeaders(Supplier<Map<String, String>> customHeadersSupplier) A supplier for dynamic request headers of the MCP server. The supplier is called for each request, allowing headers to be updated dynamically. -
customHeaders
A supplier for dynamic request headers of the MCP server. The supplier is called for each request, allowing headers to be updated dynamically. -
timeout
The connection timeout (applied on the http client level). Application-level timeouts are handled by the MCP client itself. -
logRequests
Whether to log all requests that are sent over this transport. -
logResponses
Whether to log all responses received over this transport. -
logger
Sets a customLoggerto be used for traffic logging (both requests and responses). This logger will be used for both regular HTTP responses and Server-Sent Events (SSE) traffic. If not specified, a default logger will be used.- Parameters:
logger- an alternateLoggerto be used instead of the default one provided by Langchain4J for traffic logging.- Returns:
this.
-
executor
An optionalExecutorthat will be used for executing requests and handling responses. It will also be used for scheduling auto-reconnect attempts of the subsidiary SSE channel if that is enabled. If not provided, a default shared executor will be used. -
sslContext
Supplies a customSSLContextused when establishing HTTPS connections to the MCP server, allowing private CAs or certificates. -
setHttpVersion1_1
Forces the transport to use HTTP/1.1 instead of the default HTTP/2. -
subsidiaryChannel
Enables or disables the subsidiary SSE channel. When enabled, the transport will open an HTTP GET-based SSE stream after initialization, allowing the server to send notifications and requests to the client without the client first sending data via HTTP POST. If the server does not support the subsidiary channel (returns 405), the transport will log a warning and continue without it. If the stream breaks after being successfully established, the transport will automatically attempt to reconnect. Defaults tofalse. -
build
-