Class MCPConnector

java.lang.Object
ai.redouble.nucleo.mcp.MCPConnector

public class MCPConnector extends Object
Single attached MCP server, identified by an MCPHandle. Holds the MCPEndpoint configuration and the lazily-resolved list of MCPToolProviders pulled from listTools.

The connector is not AutoCloseable from the user's perspective; its lifecycle is owned by MCPConnectorRegistry. The registry releases the underlying MCPClient via MCPClientPool.evict(String) only when the refcount on the endpoint id drops to zero, so connectors that share an endpoint (different handles, same URL+headers) share one underlying client.

providers() is synchronized so concurrent attaches racing the same handle issue exactly one listTools JSON-RPC roundtrip; subsequent callers see the cached list. On failure the connector returns the last-known-good list (empty if never connected) and lets the next call retry; a network blip never permanently shrinks the LLM's tool surface.

Since:
0.1 (2026-05-08)
Author:
Andrey Santrosyan
  • Method Details

    • handle

      public MCPHandle handle()
    • endpoint

      public MCPEndpoint endpoint()
    • providers

      public List<MCPToolProvider> providers()
      Returns providers, lazily fetching the tool list on first call and on each subsequent call after invalidate() has dropped the cache. On transport failure returns the last-known-good list (empty if never connected) and logs the failure - the caller is not responsible for retry handling.
    • invalidate

      public void invalidate()
      Drops the cached provider list. The next providers() call re-fetches.
    • serverInfo

      public MCPServerInfo serverInfo()
    • isHealthy

      public boolean isHealthy()