Documentation
¶
Index ¶
- type Client
- func (mc *Client) CallTool(ctx context.Context, toolName string, args map[string]interface{}) (*mcp.CallToolResult, error)
- func (mc *Client) Connect(ctx context.Context) error
- func (mc *Client) Disconnect() error
- func (mc *Client) ForceReconnect(reason string)
- func (mc *Client) GetCachedToolCount(ctx context.Context) (int, error)
- func (mc *Client) GetCachedToolCountNonBlocking() int
- func (mc *Client) GetConfig() *config.ServerConfig
- func (mc *Client) GetConnectionInfo() types.ConnectionInfo
- func (mc *Client) GetConnectionStatus() map[string]interface{}
- func (mc *Client) GetContainerID() string
- func (mc *Client) GetEnvManager() interface{}
- func (mc *Client) GetLastError() error
- func (mc *Client) GetServerInfo() *mcp.InitializeResult
- func (mc *Client) GetState() types.ConnectionState
- func (mc *Client) InvalidateToolCountCache()
- func (mc *Client) IsConnected() bool
- func (mc *Client) IsConnecting() bool
- func (mc *Client) IsDockerCommand() bool
- func (mc *Client) IsUserLoggedOut() bool
- func (mc *Client) ListTools(ctx context.Context) ([]*config.ToolMetadata, error)
- func (mc *Client) RefreshOAuthTokenDirect(ctx context.Context) error
- func (mc *Client) SetConfig(config *config.ServerConfig)
- func (mc *Client) SetStateChangeCallback(...)
- func (mc *Client) SetToolDiscoveryCallback(callback func(ctx context.Context, serverName string) error)
- func (mc *Client) SetUserLoggedOut(loggedOut bool)
- func (mc *Client) ShouldRetry() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Config *config.ServerConfig // Public field for compatibility with existing code
StateManager *types.StateManager // Public field for callback access
// contains filtered or unexported fields
}
Client wraps a core client with state management, concurrency control, and background recovery
func NewClient ¶
func NewClient(id string, serverConfig *config.ServerConfig, logger *zap.Logger, logConfig *config.LogConfig, globalConfig *config.Config, storage *storage.BoltDB, secretResolver *secret.Resolver) (*Client, error)
NewClient creates a new managed client with state management
func (*Client) CallTool ¶
func (mc *Client) CallTool(ctx context.Context, toolName string, args map[string]interface{}) (*mcp.CallToolResult, error)
CallTool executes a tool with error handling
func (*Client) Connect ¶
Connect establishes connection with state management. IMPORTANT: mc.mu is only held briefly for state checks/transitions, NOT during the potentially slow coreClient.Connect() call (which may involve OAuth flows taking minutes). This prevents blocking Disconnect, SetConfig, GetConfig, and other callers.
func (*Client) Disconnect ¶
Disconnect closes the connection and stops monitoring
func (*Client) ForceReconnect ¶
ForceReconnect triggers an immediate reconnection attempt regardless of backoff state.
func (*Client) GetCachedToolCount ¶
GetCachedToolCount returns the cached tool count or fetches fresh count if cache is expired Uses a 2-minute cache TTL to reduce frequent ListTools calls
func (*Client) GetCachedToolCountNonBlocking ¶
GetCachedToolCountNonBlocking returns the cached tool count without any blocking calls Returns 0 if cache is not populated yet. Safe to call from SSE/API handlers.
func (*Client) GetConfig ¶
func (mc *Client) GetConfig() *config.ServerConfig
GetConfig returns a thread-safe copy of the server configuration
func (*Client) GetConnectionInfo ¶
func (mc *Client) GetConnectionInfo() types.ConnectionInfo
GetConnectionInfo returns detailed connection information
func (*Client) GetConnectionStatus ¶
GetConnectionStatus returns detailed connection status information for compatibility
func (*Client) GetContainerID ¶
GetContainerID returns the Docker container ID if this is a Docker-based server
func (*Client) GetEnvManager ¶
func (mc *Client) GetEnvManager() interface{}
GetEnvManager returns the environment manager for testing purposes
func (*Client) GetLastError ¶
GetLastError returns the last error from the state manager
func (*Client) GetServerInfo ¶
func (mc *Client) GetServerInfo() *mcp.InitializeResult
GetServerInfo returns server information
func (*Client) GetState ¶
func (mc *Client) GetState() types.ConnectionState
GetState returns the current connection state
func (*Client) InvalidateToolCountCache ¶
func (mc *Client) InvalidateToolCountCache()
InvalidateToolCountCache clears the tool count cache Should be called when tools are known to have changed
func (*Client) IsConnected ¶
IsConnected returns whether the client is ready for operations
func (*Client) IsConnecting ¶
IsConnecting returns whether the client is in a connecting state
func (*Client) IsDockerCommand ¶
IsDockerCommand returns whether this client is running a Docker command
func (*Client) IsUserLoggedOut ¶
IsUserLoggedOut returns true if the user has explicitly logged out
func (*Client) RefreshOAuthTokenDirect ¶ added in v0.17.3
RefreshOAuthTokenDirect forces an OAuth token refresh without reconnecting. This delegates to the core client's direct refresh implementation. Used by the RefreshManager for proactive token refresh before expiration.
func (*Client) SetConfig ¶
func (mc *Client) SetConfig(config *config.ServerConfig)
SetConfig updates the server configuration in a thread-safe manner
func (*Client) SetStateChangeCallback ¶
func (mc *Client) SetStateChangeCallback(callback func(oldState, newState types.ConnectionState, info *types.ConnectionInfo))
SetStateChangeCallback sets a callback for state changes
func (*Client) SetToolDiscoveryCallback ¶
func (mc *Client) SetToolDiscoveryCallback(callback func(ctx context.Context, serverName string) error)
SetToolDiscoveryCallback sets the callback for triggering tool re-indexing when a notifications/tools/list_changed notification is received from the upstream server.
func (*Client) SetUserLoggedOut ¶
SetUserLoggedOut marks that the user has explicitly logged out This prevents automatic reconnection until cleared (e.g., by explicit login)
func (*Client) ShouldRetry ¶
ShouldRetry returns whether connection should be retried