Class StdioTransport.Builder

java.lang.Object
com.tnsai.mcp.client.StdioTransport.Builder
Enclosing class:
StdioTransport

public static class StdioTransport.Builder extends Object
Builder for creating StdioTransport instances with custom configuration.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • command

      public StdioTransport.Builder command(String... command)
      Sets the command to execute.
      Parameters:
      command - the command and arguments
      Returns:
      this builder
    • environment

      public StdioTransport.Builder environment(String key, String value)
      Adds an environment variable for the process.
      Parameters:
      key - the environment variable name
      value - the environment variable value
      Returns:
      this builder
    • environment

      public StdioTransport.Builder environment(Map<String,String> environment)
      Adds multiple environment variables for the process.
      Parameters:
      environment - the environment variables map
      Returns:
      this builder
    • workingDirectory

      public StdioTransport.Builder workingDirectory(String workingDirectory)
      Sets the working directory for the process.
      Parameters:
      workingDirectory - the working directory path
      Returns:
      this builder
    • maxRetries

      public StdioTransport.Builder maxRetries(int maxRetries)
      Sets the maximum number of reconnection attempts.
      Parameters:
      maxRetries - the maximum number of retries (default: 5)
      Returns:
      this builder
    • initialRetryDelay

      public StdioTransport.Builder initialRetryDelay(Duration initialRetryDelay)
      Sets the initial delay between reconnection attempts.
      Parameters:
      initialRetryDelay - the initial delay (default: 500ms)
      Returns:
      this builder
    • maxRetryDelay

      public StdioTransport.Builder maxRetryDelay(Duration maxRetryDelay)
      Sets the maximum delay between reconnection attempts.
      Parameters:
      maxRetryDelay - the maximum delay (default: 30s)
      Returns:
      this builder
    • processStartTimeout

      public StdioTransport.Builder processStartTimeout(Duration processStartTimeout)
      Sets the timeout for process startup.
      Parameters:
      processStartTimeout - the startup timeout (default: 10s)
      Returns:
      this builder
    • healthCheckInterval

      public StdioTransport.Builder healthCheckInterval(Duration healthCheckInterval)
      Sets the interval for health checks. Set to Duration.ZERO to disable health checks.
      Parameters:
      healthCheckInterval - the health check interval (default: 30s)
      Returns:
      this builder
    • shutdownTimeout

      public StdioTransport.Builder shutdownTimeout(Duration shutdownTimeout)
      Sets the timeout for graceful shutdown.
      Parameters:
      shutdownTimeout - the shutdown timeout (default: 5s)
      Returns:
      this builder
    • autoReconnect

      public StdioTransport.Builder autoReconnect(boolean autoReconnect)
      Enables or disables automatic reconnection.
      Parameters:
      autoReconnect - true to enable auto-reconnect (default: true)
      Returns:
      this builder
    • build

      public StdioTransport build()
      Builds the StdioTransport instance.
      Returns:
      a new StdioTransport instance