managed

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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

func (mc *Client) Connect(ctx context.Context) error

Connect establishes connection with state management

func (*Client) Disconnect

func (mc *Client) Disconnect() error

Disconnect closes the connection and stops monitoring

func (*Client) ForceReconnect

func (mc *Client) ForceReconnect(reason string)

ForceReconnect triggers an immediate reconnection attempt regardless of backoff state.

func (*Client) GetCachedToolCount

func (mc *Client) GetCachedToolCount(ctx context.Context) (int, error)

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

func (mc *Client) GetCachedToolCountNonBlocking() int

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

func (mc *Client) GetConnectionStatus() map[string]interface{}

GetConnectionStatus returns detailed connection status information for compatibility

func (*Client) GetContainerID

func (mc *Client) GetContainerID() string

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

func (mc *Client) GetLastError() error

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

func (mc *Client) IsConnected() bool

IsConnected returns whether the client is ready for operations

func (*Client) IsConnecting

func (mc *Client) IsConnecting() bool

IsConnecting returns whether the client is in a connecting state

func (*Client) IsDockerCommand

func (mc *Client) IsDockerCommand() bool

IsDockerCommand returns whether this client is running a Docker command

func (*Client) IsUserLoggedOut

func (mc *Client) IsUserLoggedOut() bool

IsUserLoggedOut returns true if the user has explicitly logged out

func (*Client) ListTools

func (mc *Client) ListTools(ctx context.Context) ([]*config.ToolMetadata, error)

ListTools retrieves tools with concurrency control

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

func (mc *Client) SetUserLoggedOut(loggedOut bool)

SetUserLoggedOut marks that the user has explicitly logged out This prevents automatic reconnection until cleared (e.g., by explicit login)

func (*Client) ShouldRetry

func (mc *Client) ShouldRetry() bool

ShouldRetry returns whether connection should be retried

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL