Class ConnectionFactory

java.lang.Object
com.shaft.commandline.runtime.ConnectionFactory
All Implemented Interfaces:
McpConnector

public final class ConnectionFactory extends Object implements McpConnector
Chooses the MCP transport for a command per the routing rule: if a daemon session is live, connect to it over streamable HTTP (so browser/device state persists); otherwise spawn an ephemeral stdio child. Commands that require live state fail fast when no daemon is running unless --stdio-ok.
  • Constructor Details

    • ConnectionFactory

      public ConnectionFactory()
      Uses the real session manager and launcher locator.
    • ConnectionFactory

      public ConnectionFactory(SessionManager sessionManager, McpLauncherLocator locator)
      Parameters:
      sessionManager - the session manager
      locator - the launcher locator
  • Method Details

    • connect

      public McpClient connect(boolean requiresSession, boolean stdioOk)
      Specified by:
      connect in interface McpConnector
      Parameters:
      requiresSession - whether the command needs persistent live state (browser/element/capture)
      stdioOk - whether the caller opted in to a throwaway one-shot server
      Returns:
      a connected MCP client the caller must close