Record Class NetworkConfig

java.lang.Object
java.lang.Record
dev.tachyonmcp.core.server.config.NetworkConfig
Record Components:
host - bind address (default "127.0.0.1")
port - listen port (must be set before bind())
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 value
writerIdleTimeout - idle timeout for writing (default 5min)
maxContentLength - maximum HTTP body size in bytes
allowedOrigins - CORS allowed origins (null = defaults)
allowNullOrigin - whether to allow Origin: null
allowPrivateNetworks - whether to allow private network CORS
allowedHeaders - additional allowed CORS headers
ioEngine - Netty I/O engine; defaults to NettyIoEngine.AUTO
heartbeatInterval - SSE heartbeat interval that keeps an upgraded stream alive (default 15s); keep below readerIdleTimeout; <= 0 disables

@ExperimentalApi public record 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) extends Record
Network-level server configuration.

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.

  • Field Details

    • DEFAULT_HOST

      public static final String DEFAULT_HOST
      See Also:
    • UNSET_PORT

      public static final int UNSET_PORT
      See Also:
    • DEFAULT_ENDPOINT_PATH

      public static final String DEFAULT_ENDPOINT_PATH
      See Also:
    • DEFAULT_READER_IDLE_TIMEOUT

      public static final Duration DEFAULT_READER_IDLE_TIMEOUT
    • DEFAULT_WRITER_IDLE_TIMEOUT

      public static final Duration DEFAULT_WRITER_IDLE_TIMEOUT
    • DEFAULT_HEARTBEAT_INTERVAL

      public static final Duration 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 a NetworkConfig record class.
      Parameters:
      host - the value for the host record component
      port - the value for the port record component
      endpointPath - the value for the endpointPath record component
      readerIdleTimeout - the value for the readerIdleTimeout record component
      writerIdleTimeout - the value for the writerIdleTimeout record component
      maxContentLength - the value for the maxContentLength record component
      allowedOrigins - the value for the allowedOrigins record component
      allowNullOrigin - the value for the allowNullOrigin record component
      allowPrivateNetworks - the value for the allowPrivateNetworks record component
      allowedHeaders - the value for the allowedHeaders record component
      ioEngine - the value for the ioEngine record component
      heartbeatInterval - the value for the heartbeatInterval record component
  • Method Details

    • builder

      public static NetworkConfig.Builder builder()
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • host

      public String host()
      Returns the value of the host record component.
      Returns:
      the value of the host record component
    • port

      public int port()
      Returns the value of the port record component.
      Returns:
      the value of the port record component
    • endpointPath

      public String endpointPath()
      Returns the value of the endpointPath record component.
      Returns:
      the value of the endpointPath record component
    • readerIdleTimeout

      public Duration readerIdleTimeout()
      Returns the value of the readerIdleTimeout record component.
      Returns:
      the value of the readerIdleTimeout record component
    • writerIdleTimeout

      public Duration writerIdleTimeout()
      Returns the value of the writerIdleTimeout record component.
      Returns:
      the value of the writerIdleTimeout record component
    • maxContentLength

      public int maxContentLength()
      Returns the value of the maxContentLength record component.
      Returns:
      the value of the maxContentLength record component
    • allowedOrigins

      public @Nullable List<String> allowedOrigins()
      Returns the value of the allowedOrigins record component.
      Returns:
      the value of the allowedOrigins record component
    • allowNullOrigin

      public boolean allowNullOrigin()
      Returns the value of the allowNullOrigin record component.
      Returns:
      the value of the allowNullOrigin record component
    • allowPrivateNetworks

      public boolean allowPrivateNetworks()
      Returns the value of the allowPrivateNetworks record component.
      Returns:
      the value of the allowPrivateNetworks record component
    • allowedHeaders

      public @Nullable List<String> allowedHeaders()
      Returns the value of the allowedHeaders record component.
      Returns:
      the value of the allowedHeaders record component
    • ioEngine

      public NettyIoEngine ioEngine()
      Returns the value of the ioEngine record component.
      Returns:
      the value of the ioEngine record component
    • heartbeatInterval

      public Duration heartbeatInterval()
      Returns the value of the heartbeatInterval record component.
      Returns:
      the value of the heartbeatInterval record component