Documentation
¶
Index ¶
- type ApplicationContext
- func (ctx *ApplicationContext) Close() error
- func (ctx *ApplicationContext) GetCacheManager() CacheManager
- func (ctx *ApplicationContext) GetDockerIsolationManager() DockerIsolationManager
- func (ctx *ApplicationContext) GetIndexManager() IndexManager
- func (ctx *ApplicationContext) GetLogManager() LogManager
- func (ctx *ApplicationContext) GetOAuthTokenManager() OAuthTokenManager
- func (ctx *ApplicationContext) GetStorageManager() StorageManager
- func (ctx *ApplicationContext) GetUpstreamManager() UpstreamManager
- type CacheManager
- type CacheManagerAdapter
- func (c *CacheManagerAdapter) Clear() error
- func (c *CacheManagerAdapter) Close() error
- func (c *CacheManagerAdapter) Delete(_ string) error
- func (c *CacheManagerAdapter) Expire(_ string) error
- func (c *CacheManagerAdapter) Get(key string) (interface{}, bool)
- func (c *CacheManagerAdapter) GetHitRate() float64
- func (c *CacheManagerAdapter) GetStats() map[string]interface{}
- func (c *CacheManagerAdapter) GetTTL(_ string) (time.Duration, error)
- func (c *CacheManagerAdapter) Set(key string, value interface{}, _ time.Duration) error
- func (c *CacheManagerAdapter) SetTTL(_ string, _ time.Duration) error
- type DockerIsolationManager
- type DockerIsolationManagerImpl
- func (d *DockerIsolationManagerImpl) CleanupContainer(containerID string) error
- func (d *DockerIsolationManagerImpl) GetContainerStats(_ string) (map[string]interface{}, error)
- func (d *DockerIsolationManagerImpl) GetDefaultImage(command string) string
- func (d *DockerIsolationManagerImpl) GetDockerIsolationWarning(serverConfig *config.ServerConfig) string
- func (d *DockerIsolationManagerImpl) IsDockerAvailable() bool
- func (d *DockerIsolationManagerImpl) SetDefaultImages(images map[string]string) error
- func (d *DockerIsolationManagerImpl) SetResourceLimits(memory, cpu string) error
- func (d *DockerIsolationManagerImpl) ShouldIsolate(command string, args []string) bool
- func (d *DockerIsolationManagerImpl) StartIsolatedCommand(_ context.Context, command string, args []string, _ map[string]string, ...) (interface{}, error)
- func (d *DockerIsolationManagerImpl) StopContainer(containerID string) error
- type IndexManager
- type LogManager
- type LogManagerImpl
- func (l *LogManagerImpl) Close() error
- func (l *LogManagerImpl) CreateLogger(name string, _ *config.LogConfig) *zap.Logger
- func (l *LogManagerImpl) GetLogContent(_ string, _ int) ([]string, error)
- func (l *LogManagerImpl) GetLogFiles() ([]string, error)
- func (l *LogManagerImpl) GetLogLevel() string
- func (l *LogManagerImpl) GetMainLogger() *zap.Logger
- func (l *LogManagerImpl) GetServerLogger(serverName string) *zap.Logger
- func (l *LogManagerImpl) RotateLogs() error
- func (l *LogManagerImpl) SetLogLevel(level string) error
- func (l *LogManagerImpl) Sync() error
- func (l *LogManagerImpl) UpdateLogConfig(config *config.LogConfig) error
- type NotificationHandler
- type NotificationHandlerAdapter
- type OAuthTokenManager
- type OAuthTokenManagerImpl
- func (o *OAuthTokenManagerImpl) ClearToken(serverName string) error
- func (o *OAuthTokenManagerImpl) GetOrCreateTokenStore(serverName string) client.TokenStore
- func (o *OAuthTokenManagerImpl) GetToken(serverName string) (interface{}, error)
- func (o *OAuthTokenManagerImpl) HasTokenStore(serverName string) bool
- func (o *OAuthTokenManagerImpl) NotifyOAuthCompletion(serverName string)
- func (o *OAuthTokenManagerImpl) SaveToken(serverName string, _ interface{}) error
- func (o *OAuthTokenManagerImpl) SetOAuthCompletionCallback(callback func(serverName string))
- type StorageManager
- type UpstreamManager
- type UpstreamManagerAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplicationContext ¶
type ApplicationContext struct {
// Core interfaces
UpstreamManager UpstreamManager
IndexManager IndexManager
StorageManager StorageManager
OAuthTokenManager OAuthTokenManager
DockerIsolationManager DockerIsolationManager
LogManager LogManager
CacheManager CacheManager
// Configuration
Config *config.Config
LogConfig *config.LogConfig
// Core logger
Logger *zap.Logger
}
ApplicationContext holds all application dependencies using interfaces
func NewApplicationContext ¶
func NewApplicationContext(cfg *config.Config, logConfig *config.LogConfig, logger *zap.Logger) (*ApplicationContext, error)
NewApplicationContext creates a new application context with concrete implementations
func (*ApplicationContext) Close ¶
func (ctx *ApplicationContext) Close() error
Close gracefully shuts down all managers
func (*ApplicationContext) GetCacheManager ¶
func (ctx *ApplicationContext) GetCacheManager() CacheManager
GetCacheManager returns the cache manager interface
func (*ApplicationContext) GetDockerIsolationManager ¶
func (ctx *ApplicationContext) GetDockerIsolationManager() DockerIsolationManager
GetDockerIsolationManager returns the Docker isolation manager interface
func (*ApplicationContext) GetIndexManager ¶
func (ctx *ApplicationContext) GetIndexManager() IndexManager
GetIndexManager returns the index manager interface
func (*ApplicationContext) GetLogManager ¶
func (ctx *ApplicationContext) GetLogManager() LogManager
GetLogManager returns the log manager interface
func (*ApplicationContext) GetOAuthTokenManager ¶
func (ctx *ApplicationContext) GetOAuthTokenManager() OAuthTokenManager
GetOAuthTokenManager returns the OAuth token manager interface
func (*ApplicationContext) GetStorageManager ¶
func (ctx *ApplicationContext) GetStorageManager() StorageManager
GetStorageManager returns the storage manager interface
func (*ApplicationContext) GetUpstreamManager ¶
func (ctx *ApplicationContext) GetUpstreamManager() UpstreamManager
GetUpstreamManager returns the upstream manager interface
type CacheManager ¶
type CacheManager interface {
// Cache operations
Get(key string) (interface{}, bool)
Set(key string, value interface{}, ttl time.Duration) error
Delete(key string) error
Clear() error
// Cache statistics
GetStats() map[string]interface{}
GetHitRate() float64
// Cache management
SetTTL(key string, ttl time.Duration) error
GetTTL(key string) (time.Duration, error)
Expire(key string) error
// Lifecycle
Close() error
}
CacheManager interface defines contract for response caching operations
type CacheManagerAdapter ¶
CacheManagerAdapter adapts cache.Manager to our CacheManager interface
func (*CacheManagerAdapter) Clear ¶
func (c *CacheManagerAdapter) Clear() error
Clear clears all cache entries
func (*CacheManagerAdapter) Close ¶
func (c *CacheManagerAdapter) Close() error
Close closes the cache manager
func (*CacheManagerAdapter) Delete ¶
func (c *CacheManagerAdapter) Delete(_ string) error
Delete removes a cache entry
func (*CacheManagerAdapter) Expire ¶
func (c *CacheManagerAdapter) Expire(_ string) error
Expire expires a cache entry
func (*CacheManagerAdapter) Get ¶
func (c *CacheManagerAdapter) Get(key string) (interface{}, bool)
Get adapts the cache manager Get method
func (*CacheManagerAdapter) GetHitRate ¶
func (c *CacheManagerAdapter) GetHitRate() float64
GetHitRate returns the cache hit rate
func (*CacheManagerAdapter) GetStats ¶
func (c *CacheManagerAdapter) GetStats() map[string]interface{}
GetStats returns cache statistics
func (*CacheManagerAdapter) GetTTL ¶
func (c *CacheManagerAdapter) GetTTL(_ string) (time.Duration, error)
GetTTL gets TTL for a cache entry
type DockerIsolationManager ¶
type DockerIsolationManager interface {
// Isolation detection and management
ShouldIsolate(command string, args []string) bool
IsDockerAvailable() bool
GetDockerIsolationWarning(serverConfig *config.ServerConfig) string
// Container lifecycle
StartIsolatedCommand(ctx context.Context, command string, args []string, env map[string]string, workingDir string) (interface{}, error) // Returns Process or equivalent
StopContainer(containerID string) error
CleanupContainer(containerID string) error
// Resource management
SetResourceLimits(memory, cpu string) error
GetContainerStats(containerID string) (map[string]interface{}, error)
// Configuration
GetDefaultImage(command string) string
SetDefaultImages(images map[string]string) error
}
DockerIsolationManager interface defines contract for Docker isolation operations
type DockerIsolationManagerImpl ¶
type DockerIsolationManagerImpl struct {
// contains filtered or unexported fields
}
DockerIsolationManagerImpl implements DockerIsolationManager interface
func (*DockerIsolationManagerImpl) CleanupContainer ¶
func (d *DockerIsolationManagerImpl) CleanupContainer(containerID string) error
CleanupContainer cleans up a Docker container
func (*DockerIsolationManagerImpl) GetContainerStats ¶
func (d *DockerIsolationManagerImpl) GetContainerStats(_ string) (map[string]interface{}, error)
GetContainerStats retrieves container statistics
func (*DockerIsolationManagerImpl) GetDefaultImage ¶
func (d *DockerIsolationManagerImpl) GetDefaultImage(command string) string
GetDefaultImage returns the default Docker image for a command
func (*DockerIsolationManagerImpl) GetDockerIsolationWarning ¶
func (d *DockerIsolationManagerImpl) GetDockerIsolationWarning(serverConfig *config.ServerConfig) string
GetDockerIsolationWarning returns a warning if Docker isolation might cause issues
func (*DockerIsolationManagerImpl) IsDockerAvailable ¶
func (d *DockerIsolationManagerImpl) IsDockerAvailable() bool
IsDockerAvailable checks if Docker is available for isolation
func (*DockerIsolationManagerImpl) SetDefaultImages ¶
func (d *DockerIsolationManagerImpl) SetDefaultImages(images map[string]string) error
SetDefaultImages sets the default Docker images
func (*DockerIsolationManagerImpl) SetResourceLimits ¶
func (d *DockerIsolationManagerImpl) SetResourceLimits(memory, cpu string) error
SetResourceLimits sets Docker resource limits
func (*DockerIsolationManagerImpl) ShouldIsolate ¶
func (d *DockerIsolationManagerImpl) ShouldIsolate(command string, args []string) bool
ShouldIsolate determines if a command should be run in Docker isolation
func (*DockerIsolationManagerImpl) StartIsolatedCommand ¶
func (d *DockerIsolationManagerImpl) StartIsolatedCommand(_ context.Context, command string, args []string, _ map[string]string, workingDir string) (interface{}, error)
StartIsolatedCommand starts a command in Docker isolation
func (*DockerIsolationManagerImpl) StopContainer ¶
func (d *DockerIsolationManagerImpl) StopContainer(containerID string) error
StopContainer stops a Docker container
type IndexManager ¶
type IndexManager interface {
// Tool indexing
IndexTool(toolMeta *config.ToolMetadata) error
BatchIndexTools(tools []*config.ToolMetadata) error
// Search operations
SearchTools(query string, limit int) ([]*config.SearchResult, error)
Search(query string, limit int) ([]*config.SearchResult, error)
// Tool management
DeleteTool(serverName, toolName string) error
DeleteServerTools(serverName string) error
GetToolsByServer(serverName string) ([]*config.ToolMetadata, error)
// Index management
RebuildIndex() error
GetDocumentCount() (uint64, error)
GetStats() (map[string]interface{}, error)
// Lifecycle
Close() error
}
IndexManager interface defines contract for search indexing operations
type LogManager ¶
type LogManager interface {
// Logger creation
GetServerLogger(serverName string) *zap.Logger
GetMainLogger() *zap.Logger
CreateLogger(name string, config *config.LogConfig) *zap.Logger
// Log management
RotateLogs() error
GetLogFiles() ([]string, error)
GetLogContent(logFile string, lines int) ([]string, error)
// Configuration
SetLogLevel(level string) error
GetLogLevel() string
UpdateLogConfig(config *config.LogConfig) error
// Lifecycle
Sync() error
Close() error
}
LogManager interface defines contract for logging operations
type LogManagerImpl ¶
type LogManagerImpl struct {
// contains filtered or unexported fields
}
LogManagerImpl implements LogManager interface
func (*LogManagerImpl) CreateLogger ¶
CreateLogger creates a logger with the given configuration
func (*LogManagerImpl) GetLogContent ¶
func (l *LogManagerImpl) GetLogContent(_ string, _ int) ([]string, error)
GetLogContent returns content of a log file
func (*LogManagerImpl) GetLogFiles ¶
func (l *LogManagerImpl) GetLogFiles() ([]string, error)
GetLogFiles returns list of log files
func (*LogManagerImpl) GetLogLevel ¶
func (l *LogManagerImpl) GetLogLevel() string
GetLogLevel returns the current logging level
func (*LogManagerImpl) GetMainLogger ¶
func (l *LogManagerImpl) GetMainLogger() *zap.Logger
GetMainLogger returns the main application logger
func (*LogManagerImpl) GetServerLogger ¶
func (l *LogManagerImpl) GetServerLogger(serverName string) *zap.Logger
GetServerLogger returns a logger for a specific server
func (*LogManagerImpl) RotateLogs ¶
func (l *LogManagerImpl) RotateLogs() error
RotateLogs rotates log files
func (*LogManagerImpl) SetLogLevel ¶
func (l *LogManagerImpl) SetLogLevel(level string) error
SetLogLevel sets the logging level
func (*LogManagerImpl) Sync ¶
func (l *LogManagerImpl) Sync() error
Sync flushes any buffered log entries
func (*LogManagerImpl) UpdateLogConfig ¶
func (l *LogManagerImpl) UpdateLogConfig(config *config.LogConfig) error
UpdateLogConfig updates the log configuration
type NotificationHandler ¶
type NotificationHandler interface {
SendNotification(notification interface{})
}
NotificationHandler defines the interface for handling notifications This is a simplified version to avoid circular dependencies
type NotificationHandlerAdapter ¶
type NotificationHandlerAdapter struct {
// contains filtered or unexported fields
}
NotificationHandlerAdapter adapts our NotificationHandler interface to upstream.NotificationHandler
func (*NotificationHandlerAdapter) SendNotification ¶
func (n *NotificationHandlerAdapter) SendNotification(notification *upstream.Notification)
SendNotification implements upstream.NotificationHandler
type OAuthTokenManager ¶
type OAuthTokenManager interface {
// Token store management
GetOrCreateTokenStore(serverName string) client.TokenStore
HasTokenStore(serverName string) bool
// OAuth completion callbacks
SetOAuthCompletionCallback(callback func(serverName string))
NotifyOAuthCompletion(serverName string)
// Token persistence (for persistent stores)
GetToken(serverName string) (interface{}, error) // Returns oauth2.Token or equivalent
SaveToken(serverName string, token interface{}) error
ClearToken(serverName string) error
}
OAuthTokenManager interface defines contract for OAuth token management
type OAuthTokenManagerImpl ¶
type OAuthTokenManagerImpl struct {
// contains filtered or unexported fields
}
OAuthTokenManagerImpl implements OAuthTokenManager interface
func (*OAuthTokenManagerImpl) ClearToken ¶
func (o *OAuthTokenManagerImpl) ClearToken(serverName string) error
ClearToken clears the token for the given server
func (*OAuthTokenManagerImpl) GetOrCreateTokenStore ¶
func (o *OAuthTokenManagerImpl) GetOrCreateTokenStore(serverName string) client.TokenStore
GetOrCreateTokenStore returns a shared token store for the given server
func (*OAuthTokenManagerImpl) GetToken ¶
func (o *OAuthTokenManagerImpl) GetToken(serverName string) (interface{}, error)
GetToken retrieves a token for the given server (from persistent store)
func (*OAuthTokenManagerImpl) HasTokenStore ¶
func (o *OAuthTokenManagerImpl) HasTokenStore(serverName string) bool
HasTokenStore checks if a token store exists for the server
func (*OAuthTokenManagerImpl) NotifyOAuthCompletion ¶
func (o *OAuthTokenManagerImpl) NotifyOAuthCompletion(serverName string)
NotifyOAuthCompletion notifies that OAuth has completed for a server
func (*OAuthTokenManagerImpl) SaveToken ¶
func (o *OAuthTokenManagerImpl) SaveToken(serverName string, _ interface{}) error
SaveToken saves a token for the given server
func (*OAuthTokenManagerImpl) SetOAuthCompletionCallback ¶
func (o *OAuthTokenManagerImpl) SetOAuthCompletionCallback(callback func(serverName string))
SetOAuthCompletionCallback sets a callback function to be called when OAuth completes
type StorageManager ¶
type StorageManager interface {
// Upstream server operations
SaveUpstreamServer(serverConfig *config.ServerConfig) error
GetUpstreamServer(name string) (*config.ServerConfig, error)
ListUpstreamServers() ([]*config.ServerConfig, error)
ListQuarantinedUpstreamServers() ([]*config.ServerConfig, error)
ListQuarantinedTools(serverName string) ([]map[string]interface{}, error)
DeleteUpstreamServer(name string) error
EnableUpstreamServer(name string, enabled bool) error
QuarantineUpstreamServer(name string, quarantined bool) error
// Tool statistics operations
IncrementToolUsage(toolName string) error
GetToolUsage(toolName string) (*storage.ToolStatRecord, error)
GetToolStatistics(topN int) (*config.ToolStats, error)
// Tool hash operations (for change detection)
SaveToolHash(toolName, hash string) error
GetToolHash(toolName string) (string, error)
HasToolChanged(toolName, currentHash string) (bool, error)
DeleteToolHash(toolName string) error
// Maintenance operations
Backup(destPath string) error
GetSchemaVersion() (uint64, error)
GetStats() (map[string]interface{}, error)
// Compatibility aliases
ListUpstreams() ([]*config.ServerConfig, error)
AddUpstream(serverConfig *config.ServerConfig) (string, error)
RemoveUpstream(id string) error
UpdateUpstream(id string, serverConfig *config.ServerConfig) error
GetToolStats(topN int) ([]map[string]interface{}, error)
// Lifecycle
Close() error
}
StorageManager interface defines contract for persistence operations
type UpstreamManager ¶
type UpstreamManager interface {
// Server lifecycle management
AddServerConfig(id string, serverConfig *config.ServerConfig) error
AddServer(id string, serverConfig *config.ServerConfig) error
RemoveServer(id string)
GetClient(id string) (*managed.Client, bool)
GetAllClients() map[string]*managed.Client
GetAllServerNames() []string
ListServers() map[string]*config.ServerConfig
// Connection management
ConnectAll(ctx context.Context) error
DisconnectAll() error
RetryConnection(serverName string) error
// Tool operations
DiscoverTools(ctx context.Context) ([]*config.ToolMetadata, error)
CallTool(ctx context.Context, toolName string, args map[string]interface{}) (interface{}, error)
InvalidateAllToolCountCaches()
// Status and statistics
GetStats() map[string]interface{}
GetTotalToolCount() int
HasDockerContainers() bool
// Configuration
SetLogConfig(logConfig *config.LogConfig)
// OAuth operations
StartManualOAuth(serverName string, force bool) error
// Notification handling
AddNotificationHandler(handler NotificationHandler)
}
UpstreamManager interface defines contract for managing upstream MCP servers
type UpstreamManagerAdapter ¶
UpstreamManagerAdapter wraps the upstream.Manager to match our interface
func (*UpstreamManagerAdapter) AddNotificationHandler ¶
func (u *UpstreamManagerAdapter) AddNotificationHandler(handler NotificationHandler)
AddNotificationHandler adapts the upstream manager's notification handler to our interface