Documentation
¶
Index ¶
- Constants
- func TagConnectionContext(ctx context.Context, source ConnectionSource) context.Context
- func ValidateDataDirectory(dataDir string, logger *zap.Logger) error
- type ConnectionSource
- type IsolationChecker
- type Listener
- type ListenerConfig
- type ListenerManager
- type MCPProxyServer
- func (p *MCPProxyServer) CallBuiltInTool(ctx context.Context, toolName string, arguments map[string]interface{}) (*mcp.CallToolResult, error)
- func (p *MCPProxyServer) CallToolDirect(ctx context.Context, request mcp.CallToolRequest) (interface{}, error)
- func (p *MCPProxyServer) Close() error
- func (p *MCPProxyServer) GetMCPServer() *mcpserver.MCPServer
- type PermissionError
- type PortInUseError
- type Server
- func (s *Server) AddServer(ctx context.Context, serverConfig *config.ServerConfig) error
- func (s *Server) ApplyConfig(cfg *config.Config, cfgPath string) (*runtime.ConfigApplyResult, error)
- func (s *Server) CallTool(ctx context.Context, toolName string, arguments map[string]interface{}) (interface{}, error)
- func (s *Server) DiscoverServerTools(ctx context.Context, serverName string) error
- func (s *Server) EnableServer(serverName string, enabled bool) error
- func (s *Server) EventsChannel() <-chan runtime.Event
- func (s *Server) ForceReconnectAllServers(reason string) error
- func (s *Server) GetActivity(id string) (*storage.ActivityRecord, error)
- func (s *Server) GetAllServers() ([]map[string]interface{}, error)
- func (s *Server) GetConfig() (*config.Config, error)
- func (s *Server) GetConfigPath() string
- func (s *Server) GetCurrentConfig() interface{}
- func (s *Server) GetDockerRecoveryStatus() *storage.DockerRecoveryState
- func (s *Server) GetListenAddress() string
- func (s *Server) GetLogDir() string
- func (s *Server) GetManagementService() interface{}
- func (s *Server) GetQuarantinedServers() ([]map[string]interface{}, error)
- func (s *Server) GetRecentSessions(limit int) ([]*contracts.MCPSession, int, error)
- func (s *Server) GetSecretResolver() *secret.Resolver
- func (s *Server) GetServerLogs(serverName string, tail int) ([]contracts.LogEntry, error)
- func (s *Server) GetServerToolCalls(serverName string, limit int) ([]*contracts.ToolCallRecord, error)
- func (s *Server) GetServerTools(serverName string) ([]map[string]interface{}, error)
- func (s *Server) GetSessionByID(sessionID string) (*contracts.MCPSession, error)
- func (s *Server) GetStatus() interface{}
- func (s *Server) GetTokenSavings() (*contracts.ServerTokenMetrics, error)
- func (s *Server) GetToolCallByID(id string) (*contracts.ToolCallRecord, error)
- func (s *Server) GetToolCalls(limit, offset int) ([]*contracts.ToolCallRecord, int, error)
- func (s *Server) GetToolCallsBySession(sessionID string, limit, offset int) ([]*contracts.ToolCallRecord, int, error)
- func (s *Server) GetUpstreamStats() map[string]interface{}
- func (s *Server) GetVersionInfo() *updatecheck.VersionInfo
- func (s *Server) IsReady() bool
- func (s *Server) IsRunning() bool
- func (s *Server) ListActivities(filter storage.ActivityFilter) ([]*storage.ActivityRecord, int, error)
- func (s *Server) ListRegistries() ([]interface{}, error)
- func (s *Server) NotifySecretsChanged(ctx context.Context, operation, secretName string) error
- func (s *Server) OnUpstreamServerChange()
- func (s *Server) QuarantineServer(serverName string, quarantined bool) error
- func (s *Server) RefreshVersionInfo() *updatecheck.VersionInfo
- func (s *Server) ReloadConfiguration() error
- func (s *Server) RemoveServer(ctx context.Context, serverName string) error
- func (s *Server) ReplayToolCall(id string, arguments map[string]interface{}) (*contracts.ToolCallRecord, error)
- func (s *Server) RestartServer(serverName string) error
- func (s *Server) SaveConfiguration() error
- func (s *Server) SearchRegistryServers(registryID, tag, query string, limit int) ([]interface{}, error)
- func (s *Server) SearchTools(query string, limit int) ([]map[string]interface{}, error)
- func (s *Server) SetListenAddress(addr string, persist bool) error
- func (s *Server) SetShutdownInfo(reason, signal string)
- func (s *Server) Shutdown() error
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) StartServer(ctx context.Context) error
- func (s *Server) StatusChannel() <-chan interface{}
- func (s *Server) StopServer() error
- func (s *Server) StreamActivities(filter storage.ActivityFilter) <-chan *storage.ActivityRecord
- func (s *Server) SubscribeEvents() chan runtime.Event
- func (s *Server) SuggestAlternateListen(baseAddr string) (string, error)
- func (s *Server) TriggerOAuthLogin(serverName string) error
- func (s *Server) UnquarantineServer(serverName string) error
- func (s *Server) UnsubscribeEvents(ch chan runtime.Event)
- func (s *Server) ValidateConfig(cfg *config.Config) ([]config.ValidationError, error)
- type SessionInfo
- type SessionStore
- func (s *SessionStore) Count() int
- func (s *SessionStore) GetSession(sessionID string) *SessionInfo
- func (s *SessionStore) RemoveSession(sessionID string)
- func (s *SessionStore) SetSession(sessionID, clientName, clientVersion string, hasRoots, hasSampling bool, ...)
- func (s *SessionStore) SetStorageManager(manager *storage.Manager)
- func (s *SessionStore) UpdateSessionStats(sessionID string, tokens int)
- type Status
- type Ucred
Constants ¶
const ( ConnectionSourceTCP = transport.ConnectionSourceTCP ConnectionSourceTray = transport.ConnectionSourceTray )
Variables ¶
This section is empty.
Functions ¶
func TagConnectionContext ¶
func TagConnectionContext(ctx context.Context, source ConnectionSource) context.Context
TagConnectionContext tags a context with the connection source TagConnectionContext wraps transport.TagConnectionContext for backward compatibility
Types ¶
type ConnectionSource ¶
type ConnectionSource = transport.ConnectionSource
Re-export transport types for backward compatibility
func GetConnectionSource ¶
func GetConnectionSource(ctx context.Context) ConnectionSource
GetConnectionSource wraps transport.GetConnectionSource for backward compatibility
type IsolationChecker ¶
type IsolationChecker interface {
ShouldIsolate(serverConfig *config.ServerConfig) bool
DetectRuntimeType(command string) string
GetDockerImage(serverConfig *config.ServerConfig, runtimeType string) (string, error)
GetDockerIsolationWarning(serverConfig *config.ServerConfig) string
}
IsolationChecker interface for checking isolation settings
type Listener ¶
type Listener struct {
net.Listener
Source ConnectionSource
Address string // Display address for logging
}
Listener wraps a net.Listener with metadata about its source
type ListenerConfig ¶
type ListenerConfig struct {
// DataDir is the data directory where socket file will be created
DataDir string
// TrayEndpoint is an optional explicit override for the tray endpoint
// Format: "unix:///path/to/socket.sock" or "npipe:////./pipe/name"
TrayEndpoint string
// TCPAddress is the address for the TCP listener (for browsers)
// Format: "127.0.0.1:8080" or ":8080"
TCPAddress string
// Logger for diagnostic output
Logger *zap.Logger
}
ListenerConfig contains configuration for creating listeners
type ListenerManager ¶
type ListenerManager struct {
// contains filtered or unexported fields
}
ListenerManager manages multiple listeners (TCP + Tray socket/pipe)
func NewListenerManager ¶
func NewListenerManager(config *ListenerConfig) *ListenerManager
NewListenerManager creates a new listener manager
func (*ListenerManager) CloseAll ¶
func (m *ListenerManager) CloseAll() error
CloseAll closes all managed listeners
func (*ListenerManager) CreateTCPListener ¶
func (m *ListenerManager) CreateTCPListener() (*Listener, error)
CreateTCPListener creates a TCP listener for browser/remote access
func (*ListenerManager) CreateTrayListener ¶
func (m *ListenerManager) CreateTrayListener() (*Listener, error)
CreateTrayListener creates a Unix socket (macOS/Linux) or named pipe (Windows) listener for tray access
func (*ListenerManager) GetListeners ¶
func (m *ListenerManager) GetListeners() []*Listener
GetListeners returns all active listeners
type MCPProxyServer ¶
type MCPProxyServer struct {
// contains filtered or unexported fields
}
MCPProxyServer implements an MCP server that acts as a proxy
func NewMCPProxyServer ¶
func NewMCPProxyServer( storage *storage.Manager, index *index.Manager, upstreamManager *upstream.Manager, cacheManager *cache.Manager, truncator *truncate.Truncator, logger *zap.Logger, mainServer *Server, debugSearch bool, config *config.Config, ) *MCPProxyServer
NewMCPProxyServer creates a new MCP proxy server
func (*MCPProxyServer) CallBuiltInTool ¶
func (p *MCPProxyServer) CallBuiltInTool(ctx context.Context, toolName string, arguments map[string]interface{}) (*mcp.CallToolResult, error)
CallBuiltInTool provides public access to built-in tools for CLI usage
func (*MCPProxyServer) CallToolDirect ¶
func (p *MCPProxyServer) CallToolDirect(ctx context.Context, request mcp.CallToolRequest) (interface{}, error)
CallToolDirect calls a tool directly without going through the MCP server's request handling This is used for REST API calls that bypass the MCP protocol layer
func (*MCPProxyServer) Close ¶
func (p *MCPProxyServer) Close() error
Close gracefully shuts down the MCP proxy server and releases resources
func (*MCPProxyServer) GetMCPServer ¶
func (p *MCPProxyServer) GetMCPServer() *mcpserver.MCPServer
GetMCPServer returns the underlying MCP server for serving
type PermissionError ¶
PermissionError represents a permission-related error (exit code 5)
func (*PermissionError) Error ¶
func (e *PermissionError) Error() string
func (*PermissionError) Unwrap ¶
func (e *PermissionError) Unwrap() error
type PortInUseError ¶
PortInUseError indicates that the requested listen address is already occupied.
func (*PortInUseError) Error ¶
func (e *PortInUseError) Error() string
func (*PortInUseError) Unwrap ¶
func (e *PortInUseError) Unwrap() error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the MCP proxy server with all its dependencies
func NewServerWithConfigPath ¶
func NewServerWithConfigPath(cfg *config.Config, configPath string, logger *zap.Logger) (*Server, error)
NewServerWithConfigPath creates a new server instance with explicit config path tracking
func (*Server) AddServer ¶
AddServer adds a new upstream server to the configuration. New servers are quarantined by default for security.
func (*Server) ApplyConfig ¶
func (s *Server) ApplyConfig(cfg *config.Config, cfgPath string) (*runtime.ConfigApplyResult, error)
ApplyConfig applies a new configuration
func (*Server) CallTool ¶
func (s *Server) CallTool(ctx context.Context, toolName string, arguments map[string]interface{}) (interface{}, error)
CallTool calls an MCP tool and returns the result
func (*Server) DiscoverServerTools ¶
DiscoverServerTools triggers manual tool discovery for a specific server
func (*Server) EnableServer ¶
EnableServer enables/disables a server and ensures all state is synchronized. It acts as the entry point for changes originating from the UI or API.
func (*Server) EventsChannel ¶
EventsChannel exposes runtime events for tray/UI consumers. Deprecated: Use SubscribeEvents for per-client subscriptions to avoid event competition.
func (*Server) ForceReconnectAllServers ¶
ForceReconnectAllServers triggers reconnection attempts for all managed servers.
func (*Server) GetActivity ¶
func (s *Server) GetActivity(id string) (*storage.ActivityRecord, error)
GetActivity returns a single activity record by ID.
func (*Server) GetAllServers ¶
GetAllServers returns information about all upstream servers for tray UI. Phase 6: Uses lock-free StateView for instant responses (<1ms) even during tool indexing.
func (*Server) GetConfigPath ¶
GetConfigPath returns the path to the configuration file for file watching
func (*Server) GetCurrentConfig ¶
func (s *Server) GetCurrentConfig() interface{}
GetCurrentConfig returns the current configuration
func (*Server) GetDockerRecoveryStatus ¶
func (s *Server) GetDockerRecoveryStatus() *storage.DockerRecoveryState
GetDockerRecoveryStatus returns the current Docker recovery status
func (*Server) GetListenAddress ¶
GetListenAddress returns the address the server is listening on
func (*Server) GetManagementService ¶
func (s *Server) GetManagementService() interface{}
GetManagementService returns the management service instance from runtime. Returns nil if service hasn't been set yet.
func (*Server) GetQuarantinedServers ¶
GetQuarantinedServers returns information about quarantined servers for tray UI
func (*Server) GetRecentSessions ¶
GetRecentSessions retrieves recent MCP sessions
func (*Server) GetSecretResolver ¶
GetSecretResolver returns the secret resolver instance
func (*Server) GetServerLogs ¶
GetServerLogs returns recent log lines for a specific server
func (*Server) GetServerToolCalls ¶
func (s *Server) GetServerToolCalls(serverName string, limit int) ([]*contracts.ToolCallRecord, error)
GetServerToolCalls retrieves tool call history for a specific server
func (*Server) GetServerTools ¶
GetServerTools returns tools for a specific server
func (*Server) GetSessionByID ¶
func (s *Server) GetSessionByID(sessionID string) (*contracts.MCPSession, error)
GetSessionByID retrieves a session by its ID
func (*Server) GetStatus ¶
func (s *Server) GetStatus() interface{}
GetStatus returns the current server status
func (*Server) GetTokenSavings ¶
func (s *Server) GetTokenSavings() (*contracts.ServerTokenMetrics, error)
GetTokenSavings calculates and returns token savings statistics
func (*Server) GetToolCallByID ¶
func (s *Server) GetToolCallByID(id string) (*contracts.ToolCallRecord, error)
GetToolCallByID retrieves a single tool call by ID
func (*Server) GetToolCalls ¶
GetToolCalls retrieves tool call history with pagination
func (*Server) GetToolCallsBySession ¶
func (s *Server) GetToolCallsBySession(sessionID string, limit, offset int) ([]*contracts.ToolCallRecord, int, error)
GetToolCallsBySession retrieves tool calls filtered by session ID
func (*Server) GetUpstreamStats ¶
GetUpstreamStats returns statistics about upstream servers
func (*Server) GetVersionInfo ¶
func (s *Server) GetVersionInfo() *updatecheck.VersionInfo
GetVersionInfo returns the current version information from the update checker.
func (*Server) IsReady ¶
IsReady returns whether the server is fully initialized and ready to serve requests
func (*Server) ListActivities ¶
func (s *Server) ListActivities(filter storage.ActivityFilter) ([]*storage.ActivityRecord, int, error)
ListActivities returns activity records matching the filter.
func (*Server) ListRegistries ¶
ListRegistries returns the list of available MCP server registries (Phase 7)
func (*Server) NotifySecretsChanged ¶
NotifySecretsChanged notifies the runtime that secrets have changed
func (*Server) OnUpstreamServerChange ¶
func (s *Server) OnUpstreamServerChange()
OnUpstreamServerChange should be called when upstream servers are modified
func (*Server) QuarantineServer ¶
QuarantineServer quarantines/unquarantines a server
func (*Server) RefreshVersionInfo ¶
func (s *Server) RefreshVersionInfo() *updatecheck.VersionInfo
RefreshVersionInfo performs an immediate update check and returns the result.
func (*Server) ReloadConfiguration ¶
ReloadConfiguration reloads the configuration from disk
func (*Server) RemoveServer ¶
RemoveServer removes an upstream server from the configuration. This stops the server if running and removes it from storage.
func (*Server) ReplayToolCall ¶
func (s *Server) ReplayToolCall(id string, arguments map[string]interface{}) (*contracts.ToolCallRecord, error)
ReplayToolCall replays a tool call with modified arguments
func (*Server) RestartServer ¶
RestartServer restarts an upstream server
func (*Server) SaveConfiguration ¶
SaveConfiguration saves the current configuration to the persistent config file
func (*Server) SearchRegistryServers ¶
func (s *Server) SearchRegistryServers(registryID, tag, query string, limit int) ([]interface{}, error)
SearchRegistryServers searches for servers in a specific registry (Phase 7)
func (*Server) SearchTools ¶
SearchTools searches for tools using the index
func (*Server) SetListenAddress ¶
SetListenAddress updates the configured listen address and optionally persists it to disk.
func (*Server) SetShutdownInfo ¶
SetShutdownInfo sets the reason and signal for shutdown (Spec 024). Call this before Shutdown() to include shutdown context in activity logs.
func (*Server) StartServer ¶
StartServer starts the server if it's not already running
func (*Server) StatusChannel ¶
func (s *Server) StatusChannel() <-chan interface{}
StatusChannel returns a channel that receives status updates
func (*Server) StopServer ¶
StopServer stops the server if it's running
func (*Server) StreamActivities ¶
func (s *Server) StreamActivities(filter storage.ActivityFilter) <-chan *storage.ActivityRecord
StreamActivities returns a channel that yields activity records matching the filter.
func (*Server) SubscribeEvents ¶
SubscribeEvents creates a new per-client event subscription channel. Each SSE client should get its own channel to avoid competing for events.
func (*Server) SuggestAlternateListen ¶
SuggestAlternateListen attempts to find an available listen address near baseAddr.
func (*Server) TriggerOAuthLogin ¶
TriggerOAuthLogin starts an in-process OAuth flow for the given server name. Used by the tray to avoid cross-process DB locking issues during OAuth.
func (*Server) UnquarantineServer ¶
UnquarantineServer removes a server from quarantine via tray UI
func (*Server) UnsubscribeEvents ¶
UnsubscribeEvents closes and removes the subscription channel.
func (*Server) ValidateConfig ¶
ValidateConfig validates a configuration
type SessionInfo ¶
SessionInfo holds MCP session metadata
type SessionStore ¶
type SessionStore struct {
// contains filtered or unexported fields
}
SessionStore manages MCP session information
func NewSessionStore ¶
func NewSessionStore(logger *zap.Logger) *SessionStore
NewSessionStore creates a new session store
func (*SessionStore) Count ¶
func (s *SessionStore) Count() int
Count returns the number of active sessions
func (*SessionStore) GetSession ¶
func (s *SessionStore) GetSession(sessionID string) *SessionInfo
GetSession retrieves session information
func (*SessionStore) RemoveSession ¶
func (s *SessionStore) RemoveSession(sessionID string)
RemoveSession removes session information
func (*SessionStore) SetSession ¶
func (s *SessionStore) SetSession(sessionID, clientName, clientVersion string, hasRoots, hasSampling bool, experimental []string)
SetSession stores or updates session information
func (*SessionStore) SetStorageManager ¶
func (s *SessionStore) SetStorageManager(manager *storage.Manager)
SetStorageManager sets the storage manager for persistence
func (*SessionStore) UpdateSessionStats ¶
func (s *SessionStore) UpdateSessionStats(sessionID string, tokens int)
UpdateSessionStats updates token usage for a session
type Status ¶
type Status struct {
Phase string `json:"phase"` // Starting, Ready, Error
Message string `json:"message"` // Human readable status message
UpstreamStats map[string]interface{} `json:"upstream_stats"` // Upstream server statistics
ToolsIndexed int `json:"tools_indexed"` // Number of tools indexed
LastUpdated time.Time `json:"last_updated"`
}
Status represents the current status of the server