Documentation
¶
Index ¶
- func GetInstanceID() string
- func IsOAuthPending(err error) bool
- type Client
- func (c *Client) CallTool(ctx context.Context, toolName string, args map[string]interface{}) (*mcp.CallToolResult, error)
- func (c *Client) CheckConnectionHealth(ctx context.Context) error
- func (c *Client) ClearOAuthState()
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) Disconnect() error
- func (c *Client) DisconnectWithContext(_ context.Context) error
- func (c *Client) ForceOAuthFlow(ctx context.Context) error
- func (c *Client) ForceOAuthFlowWithResult(ctx context.Context) (*OAuthStartResult, error)
- func (c *Client) GetConfig() *config.ServerConfig
- func (c *Client) GetConnectionDiagnostics() map[string]interface{}
- func (c *Client) GetConnectionInfo() types.ConnectionInfo
- func (c *Client) GetContainerID() string
- func (c *Client) GetEnvManager() interface{}
- func (c *Client) GetOAuthHandler() *transport.OAuthHandler
- func (c *Client) GetServerInfo() *mcp.InitializeResult
- func (c *Client) GetStderr() io.Reader
- func (c *Client) GetTransportType() string
- func (c *Client) IsConnected() bool
- func (c *Client) ListTools(ctx context.Context) ([]*config.ToolMetadata, error)
- func (c *Client) RefreshOAuthTokenDirect(ctx context.Context) error
- func (c *Client) SetOnToolsChangedCallback(callback func(serverName string))
- func (c *Client) StartOAuthFlowQuick(ctx context.Context) (*OAuthStartResult, error)
- func (c *Client) StartProcessMonitoring()
- func (c *Client) StartStderrMonitoring()
- func (c *Client) StopProcessMonitoring()
- func (c *Client) StopStderrMonitoring()
- type ContainerLock
- type ErrOAuthPending
- type IsolationManager
- func (im *IsolationManager) BuildDockerArgs(serverConfig *config.ServerConfig, runtimeType string) ([]string, error)
- func (im *IsolationManager) DetectRuntimeType(command string) string
- func (im *IsolationManager) GetDockerImage(serverConfig *config.ServerConfig, runtimeType string) (string, error)
- func (im *IsolationManager) GetDockerIsolationWarning(serverConfig *config.ServerConfig) string
- func (im *IsolationManager) HasLocalFilePath(serverConfig *config.ServerConfig) bool
- func (im *IsolationManager) ShouldIsolate(serverConfig *config.ServerConfig) bool
- func (im *IsolationManager) TransformCommandForContainer(command string, args []string, runtimeType string) (containerCommand string, containerArgs []string)
- type OAuthParameterError
- type OAuthStartResult
- type ProcessGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetInstanceID ¶
func GetInstanceID() string
GetInstanceID returns the unique identifier for this mcpproxy instance (exported for use by manager)
func IsOAuthPending ¶
IsOAuthPending checks if an error is an ErrOAuthPending
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements basic MCP client functionality without state management
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 core MCP client
func NewClientWithOptions ¶
func NewClientWithOptions(id string, serverConfig *config.ServerConfig, logger *zap.Logger, logConfig *config.LogConfig, globalConfig *config.Config, storage *storage.BoltDB, cliDebugMode bool, secretResolver *secret.Resolver) (*Client, error)
NewClientWithOptions creates a new core MCP client with additional options
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, toolName string, args map[string]interface{}) (*mcp.CallToolResult, error)
CallTool executes a tool on the upstream server
func (*Client) CheckConnectionHealth ¶
CheckConnectionHealth performs a health check on the connection
func (*Client) ClearOAuthState ¶
func (c *Client) ClearOAuthState()
ClearOAuthState clears OAuth state (public API for manual OAuth flows)
func (*Client) DisconnectWithContext ¶
DisconnectWithContext closes the connection with context timeout
func (*Client) ForceOAuthFlow ¶
ForceOAuthFlow forces an OAuth authentication flow, bypassing rate limiting (for manual auth)
func (*Client) ForceOAuthFlowWithResult ¶
func (c *Client) ForceOAuthFlowWithResult(ctx context.Context) (*OAuthStartResult, error)
ForceOAuthFlowWithResult forces an OAuth authentication flow and returns the auth URL and browser status. This is used by Phase 3 (Spec 020) to provide the auth URL to clients even when browser opens successfully.
func (*Client) GetConfig ¶ added in v0.17.3
func (c *Client) GetConfig() *config.ServerConfig
GetConfig returns the server configuration
func (*Client) GetConnectionDiagnostics ¶
GetConnectionDiagnostics returns detailed diagnostic information about the connection
func (*Client) GetConnectionInfo ¶
func (c *Client) GetConnectionInfo() types.ConnectionInfo
GetConnectionInfo returns basic connection information
func (*Client) GetContainerID ¶
GetContainerID returns the Docker container ID if this is a Docker-based server
func (*Client) GetEnvManager ¶
func (c *Client) GetEnvManager() interface{}
GetEnvManager returns the environment manager for testing purposes
func (*Client) GetOAuthHandler ¶ added in v0.17.3
func (c *Client) GetOAuthHandler() *transport.OAuthHandler
GetOAuthHandler returns the OAuth handler if the transport supports OAuth. Returns nil if no OAuth handler is configured or transport doesn't support OAuth.
func (*Client) GetServerInfo ¶
func (c *Client) GetServerInfo() *mcp.InitializeResult
GetServerInfo returns server information from initialization
func (*Client) GetTransportType ¶
GetTransportType returns the transport type being used
func (*Client) IsConnected ¶
IsConnected returns whether the client is currently connected
func (*Client) RefreshOAuthTokenDirect ¶ added in v0.17.3
RefreshOAuthTokenDirect forces an OAuth token refresh without reconnecting. This is used by the RefreshManager for proactive token refresh. Unlike ForceReconnect (which returns early when already connected), this directly calls the OAuth handler's RefreshToken method, bypassing the IsExpired() check that would prevent refresh of still-valid tokens.
For servers using Dynamic Client Registration (DCR), the handler may not have client credentials populated. In that case, we fall back to manual refresh using stored credentials from the OAuthTokenRecord.
func (*Client) SetOnToolsChangedCallback ¶
SetOnToolsChangedCallback sets the callback invoked when a notifications/tools/list_changed notification is received from the upstream MCP server. This enables reactive tool re-indexing.
func (*Client) StartOAuthFlowQuick ¶
func (c *Client) StartOAuthFlowQuick(ctx context.Context) (*OAuthStartResult, error)
StartOAuthFlowQuick starts the OAuth flow and returns browser status immediately. Unlike ForceOAuthFlowWithResult which blocks until OAuth completes, this function: 1. Gets authorization URL synchronously (quick operation) 2. Checks HEADLESS environment variable 3. Attempts browser open and captures result 4. Returns OAuthStartResult immediately 5. Continues OAuth callback handling in a goroutine
This is used by the login API endpoint to return accurate browser_opened status without blocking the HTTP response for the full OAuth flow.
func (*Client) StartProcessMonitoring ¶
func (c *Client) StartProcessMonitoring()
StartProcessMonitoring starts monitoring the underlying process
func (*Client) StartStderrMonitoring ¶
func (c *Client) StartStderrMonitoring()
StartStderrMonitoring starts monitoring stderr output and logging it
func (*Client) StopProcessMonitoring ¶
func (c *Client) StopProcessMonitoring()
StopProcessMonitoring stops process monitoring
func (*Client) StopStderrMonitoring ¶
func (c *Client) StopStderrMonitoring()
StopStderrMonitoring stops stderr monitoring
type ContainerLock ¶
type ContainerLock struct {
// contains filtered or unexported fields
}
ContainerLock provides per-server locking for container creation This prevents race conditions where multiple goroutines try to create containers for the same server simultaneously (e.g., during ForceReconnectAll)
type ErrOAuthPending ¶
ErrOAuthPending represents a deferred OAuth authentication requirement. This error indicates that OAuth is required but has been intentionally deferred (e.g., for user action via tray UI or CLI) rather than being a connection failure.
func (*ErrOAuthPending) Error ¶
func (e *ErrOAuthPending) Error() string
type IsolationManager ¶
type IsolationManager struct {
// contains filtered or unexported fields
}
IsolationManager handles Docker isolation logic for MCP servers
func NewIsolationManager ¶
func NewIsolationManager(globalConfig *config.DockerIsolationConfig) *IsolationManager
NewIsolationManager creates a new isolation manager
func (*IsolationManager) BuildDockerArgs ¶
func (im *IsolationManager) BuildDockerArgs(serverConfig *config.ServerConfig, runtimeType string) ([]string, error)
BuildDockerArgs constructs Docker run arguments for isolation
func (*IsolationManager) DetectRuntimeType ¶
func (im *IsolationManager) DetectRuntimeType(command string) string
DetectRuntimeType detects the runtime type based on the command
func (*IsolationManager) GetDockerImage ¶
func (im *IsolationManager) GetDockerImage(serverConfig *config.ServerConfig, runtimeType string) (string, error)
GetDockerImage returns the appropriate Docker image for a server
func (*IsolationManager) GetDockerIsolationWarning ¶
func (im *IsolationManager) GetDockerIsolationWarning(serverConfig *config.ServerConfig) string
GetDockerIsolationWarning returns a warning message if Docker isolation is enabled with local files
func (*IsolationManager) HasLocalFilePath ¶
func (im *IsolationManager) HasLocalFilePath(serverConfig *config.ServerConfig) bool
HasLocalFilePath checks if server arguments contain local file paths
func (*IsolationManager) ShouldIsolate ¶
func (im *IsolationManager) ShouldIsolate(serverConfig *config.ServerConfig) bool
ShouldIsolate determines if a server should be isolated based on global and server config
func (*IsolationManager) TransformCommandForContainer ¶
func (im *IsolationManager) TransformCommandForContainer(command string, args []string, runtimeType string) (containerCommand string, containerArgs []string)
TransformCommandForContainer transforms the original command to run inside the container
type OAuthParameterError ¶
type OAuthParameterError struct {
Parameter string
Location string // "authorization_url" or "token_request"
Message string
OriginalErr error
}
OAuthParameterError represents a missing or invalid OAuth parameter
func (*OAuthParameterError) Error ¶
func (e *OAuthParameterError) Error() string
func (*OAuthParameterError) Unwrap ¶
func (e *OAuthParameterError) Unwrap() error
type OAuthStartResult ¶
type OAuthStartResult struct {
AuthURL string // The authorization URL for manual use
BrowserOpened bool // Whether the browser was successfully opened
BrowserError string // Error message if browser opening failed
CorrelationID string // Unique ID for tracking this OAuth flow
}
OAuthStartResult contains the result of initiating an OAuth flow. Used by Phase 3 (Spec 020) to return auth URL and browser status synchronously.
type ProcessGroup ¶
type ProcessGroup struct {
PGID int
}
ProcessGroup represents a Unix process group for proper child process management