Class DefaultMcpClientFactory

java.lang.Object
com.tnsai.mcp.spi.DefaultMcpClientFactory
All Implemented Interfaces:
com.tnsai.spi.McpClientFactory

public final class DefaultMcpClientFactory extends Object implements com.tnsai.spi.McpClientFactory
Default McpClientFactory shipped by tnsai-mcp. Adapts a server URL into a Healthcheckable probe that performs the full MCP initialize handshake against the remote server and returns Healthcheckable.HealthStatus.healthy(Duration) only when the server completes the handshake within the supplied budget.

Discovered via ServiceLoader — the validator in tnsai-core (com.tnsai.agents.validation.validators.MCPServerReachabilityValidator, AGENT-V011) loads this implementation when tnsai-mcp is on the runtime classpath. Consumers without tnsai-mcp get graceful silent degradation.

Config map keys

Currently honoured keys
KeyTypeEffect
headers Map<String, String> HTTP headers passed to TransportDetector (typically for Authorization). Other shapes are silently ignored to keep the contract forward-compatible.

Unknown keys are ignored — the SPI documents the config map as intentionally open so future McpClientFactory implementations can carry additional knobs.

Probe semantics

The returned probe runs the entire detect → connect → initialize → disconnect cycle synchronously on the caller's thread. The validator's outer reachability harness applies the per-probe timeout via ForkJoinPool cancellation; if the probe overshoots, an AGENT-V099 INFO issue is emitted by the harness instead of an AGENT-V011 WARNING.

Since:
0.8.5 (issue #237 follow-up)
  • Constructor Details

    • DefaultMcpClientFactory

      public DefaultMcpClientFactory()
  • Method Details

    • probeFor

      public com.tnsai.spi.Healthcheckable probeFor(String serverUrl, Map<String,Object> config)
      Specified by:
      probeFor in interface com.tnsai.spi.McpClientFactory