Record Class NetworkConfig
- Record Components:
host- bind address (default"127.0.0.1")port- listen port (must be set beforebind())endpointPath- HTTP path for MCP endpoints (default"/mcp")readerIdleTimeout- close connections with no inbound traffic for this long (default 60s); long-running tools stay alive via SSE heartbeats, not a larger valuewriterIdleTimeout- idle timeout for writing (default 5min)maxContentLength- maximum HTTP body size in bytesallowedOrigins- CORS allowed origins (null= defaults)allowNullOrigin- whether to allowOrigin: nullallowPrivateNetworks- whether to allow private network CORSallowedHeaders- additional allowed CORS headersioEngine- Netty I/O engine; defaults toNettyIoEngine.AUTOheartbeatInterval- SSE heartbeat interval that keeps an upgraded stream alive (default 15s); keep belowreaderIdleTimeout;<= 0disables
Keep-alive for long-running tools. readerIdleTimeout closes any connection
that receives no inbound bytes for its duration. A client that has finished sending a
request stays silent while awaiting the reply, so this timer also runs while a handler is
computing — a tool slower than readerIdleTimeout is reaped before it can respond. The
remedy is not a larger timeout but SSE keep-alive: when a handler emits a server→client message
(e.g. progress(...)), the response upgrades to text/event-stream and a scheduler
emits a : comment heartbeat every heartbeatInterval, after which
readerIdleTimeout is a no-op on that stream. Keep
heartbeatInterval < readerIdleTimeout, and size readerIdleTimeout for dead-peer
detection rather than tool runtime.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNetworkConfig(String host, int port, String endpointPath, Duration readerIdleTimeout, Duration writerIdleTimeout, int maxContentLength, @Nullable List<String> allowedOrigins, boolean allowNullOrigin, boolean allowPrivateNetworks, @Nullable List<String> allowedHeaders, NettyIoEngine ioEngine, Duration heartbeatInterval) Creates an instance of aNetworkConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theallowedHeadersrecord component.Returns the value of theallowedOriginsrecord component.booleanReturns the value of theallowNullOriginrecord component.booleanReturns the value of theallowPrivateNetworksrecord component.static NetworkConfig.Builderbuilder()Returns the value of theendpointPathrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theheartbeatIntervalrecord component.host()Returns the value of thehostrecord component.ioEngine()Returns the value of theioEnginerecord component.intReturns the value of themaxContentLengthrecord component.intport()Returns the value of theportrecord component.Returns the value of thereaderIdleTimeoutrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thewriterIdleTimeoutrecord component.
-
Field Details
-
DEFAULT_HOST
- See Also:
-
UNSET_PORT
public static final int UNSET_PORT- See Also:
-
DEFAULT_ENDPOINT_PATH
- See Also:
-
DEFAULT_READER_IDLE_TIMEOUT
-
DEFAULT_WRITER_IDLE_TIMEOUT
-
DEFAULT_HEARTBEAT_INTERVAL
-
-
Constructor Details
-
NetworkConfig
public NetworkConfig(String host, int port, String endpointPath, Duration readerIdleTimeout, Duration writerIdleTimeout, int maxContentLength, @Nullable List<String> allowedOrigins, boolean allowNullOrigin, boolean allowPrivateNetworks, @Nullable List<String> allowedHeaders, NettyIoEngine ioEngine, Duration heartbeatInterval) Creates an instance of aNetworkConfigrecord class.- Parameters:
host- the value for thehostrecord componentport- the value for theportrecord componentendpointPath- the value for theendpointPathrecord componentreaderIdleTimeout- the value for thereaderIdleTimeoutrecord componentwriterIdleTimeout- the value for thewriterIdleTimeoutrecord componentmaxContentLength- the value for themaxContentLengthrecord componentallowedOrigins- the value for theallowedOriginsrecord componentallowNullOrigin- the value for theallowNullOriginrecord componentallowPrivateNetworks- the value for theallowPrivateNetworksrecord componentallowedHeaders- the value for theallowedHeadersrecord componentioEngine- the value for theioEnginerecord componentheartbeatInterval- the value for theheartbeatIntervalrecord component
-
-
Method Details
-
builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
host
Returns the value of thehostrecord component.- Returns:
- the value of the
hostrecord component
-
port
public int port()Returns the value of theportrecord component.- Returns:
- the value of the
portrecord component
-
endpointPath
Returns the value of theendpointPathrecord component.- Returns:
- the value of the
endpointPathrecord component
-
readerIdleTimeout
Returns the value of thereaderIdleTimeoutrecord component.- Returns:
- the value of the
readerIdleTimeoutrecord component
-
writerIdleTimeout
Returns the value of thewriterIdleTimeoutrecord component.- Returns:
- the value of the
writerIdleTimeoutrecord component
-
maxContentLength
public int maxContentLength()Returns the value of themaxContentLengthrecord component.- Returns:
- the value of the
maxContentLengthrecord component
-
allowedOrigins
Returns the value of theallowedOriginsrecord component.- Returns:
- the value of the
allowedOriginsrecord component
-
allowNullOrigin
public boolean allowNullOrigin()Returns the value of theallowNullOriginrecord component.- Returns:
- the value of the
allowNullOriginrecord component
-
allowPrivateNetworks
public boolean allowPrivateNetworks()Returns the value of theallowPrivateNetworksrecord component.- Returns:
- the value of the
allowPrivateNetworksrecord component
-
allowedHeaders
Returns the value of theallowedHeadersrecord component.- Returns:
- the value of the
allowedHeadersrecord component
-
ioEngine
Returns the value of theioEnginerecord component.- Returns:
- the value of the
ioEnginerecord component
-
heartbeatInterval
Returns the value of theheartbeatIntervalrecord component.- Returns:
- the value of the
heartbeatIntervalrecord component
-