core

package
v0.15.4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

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

func IsOAuthPending(err error) bool

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

func (c *Client) CheckConnectionHealth(ctx context.Context) error

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) Connect

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

Connect establishes connection to the upstream server

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect closes the connection

func (*Client) DisconnectWithContext

func (c *Client) DisconnectWithContext(_ context.Context) error

DisconnectWithContext closes the connection with context timeout

func (*Client) ForceOAuthFlow

func (c *Client) ForceOAuthFlow(ctx context.Context) error

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) GetConnectionDiagnostics

func (c *Client) GetConnectionDiagnostics() map[string]interface{}

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

func (c *Client) GetContainerID() string

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) GetServerInfo

func (c *Client) GetServerInfo() *mcp.InitializeResult

GetServerInfo returns server information from initialization

func (*Client) GetStderr

func (c *Client) GetStderr() io.Reader

GetStderr returns stderr reader for stdio transport

func (*Client) GetTransportType

func (c *Client) GetTransportType() string

GetTransportType returns the transport type being used

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected returns whether the client is currently connected

func (*Client) ListTools

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

ListTools retrieves available tools from the upstream server

func (*Client) SetOnToolsChangedCallback

func (c *Client) SetOnToolsChangedCallback(callback func(serverName string))

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)

func (*ContainerLock) Lock

func (cl *ContainerLock) Lock(serverName string) *sync.Mutex

Lock acquires a lock for the specified server name Returns a mutex that the caller MUST unlock when done

type ErrOAuthPending

type ErrOAuthPending struct {
	ServerName string
	ServerURL  string
	Message    string
}

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

Jump to

Keyboard shortcuts

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