Documentation
¶
Overview ¶
internal/server/k8s_manager.go
internal/server/k8s_proxy.go
internal/server/notification_integration.go
internal/server/stdio_bridge.go
Index ¶
- Variables
- type ConnectionManager
- func (cm *ConnectionManager) CleanupStaleConnections(maxIdleTime time.Duration) int
- func (cm *ConnectionManager) GetAllConnectionStats() map[string]*ConnectionMetrics
- func (cm *ConnectionManager) GetConnectionStats(serverName string) *ConnectionMetrics
- func (cm *ConnectionManager) GetConnectionSummary() map[string]interface{}
- func (cm *ConnectionManager) GetHealthCheckResults(maxResults int) []HealthCheckResult
- func (cm *ConnectionManager) HealthCheck(serverName string) HealthCheckResult
- func (cm *ConnectionManager) PerformHealthChecks()
- func (cm *ConnectionManager) RecordRequest(serverName string, success bool, responseTime time.Duration)
- func (cm *ConnectionManager) StartMonitoring(interval time.Duration)
- type ConnectionMetrics
- type ConnectionStats
- type EnhancedMCPSSEConnection
- type HealthCheckResult
- type K8sManager
- type K8sServerInstance
- type MCPError
- type MCPHTTPConnection
- type MCPRequest
- type MCPResponse
- type MCPSSEConnection
- type MCPSTDIOConnection
- type MCPStreamableHTTPConnection
- type Manager
- func (m *Manager) GetServerInstance(serverName string) (*ServerInstance, bool)
- func (m *Manager) GetServerStatus(name string) (string, error)
- func (m *Manager) ShowLogs(name string, follow bool) error
- func (m *Manager) Shutdown() error
- func (m *Manager) StartServer(name string) error
- func (m *Manager) StopServer(name string) error
- type ProxyHandler
- func (h *ProxyHandler) CheckAuth(r *http.Request) bool
- func (h *ProxyHandler) CorsError(w http.ResponseWriter, message string, statusCode int)
- func (h *ProxyHandler) DiscoverServerTools(serverName string) ([]Tool, error)
- func (h *ProxyHandler) FindServerForTool(toolName string) (string, bool)
- func (h *ProxyHandler) GetConnectionStatus() map[string]discovery.ConnectionStatus
- func (h *ProxyHandler) GetDiscoveredServers() []discovery.ServiceEndpoint
- func (h *ProxyHandler) GetProxyInfo() map[string]interface{}
- func (h *ProxyHandler) HandleDirectToolCall(w http.ResponseWriter, r *http.Request, toolName string)
- func (h *ProxyHandler) HandleMCPRequest(w http.ResponseWriter, r *http.Request, serverName string)
- func (h *ProxyHandler) RefreshConnections() error
- func (h *ProxyHandler) SendHTTPToolCall(conn *discovery.MCPConnection, request map[string]interface{}) (map[string]interface{}, error)
- func (h *ProxyHandler) SendSSEToolCall(conn *discovery.MCPConnection, request map[string]interface{}) (map[string]interface{}, error)
- func (h *ProxyHandler) SendStreamableHTTPToolCall(serverName string, request map[string]interface{}) (map[string]interface{}, error)
- func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (h *ProxyHandler) SetCORSHeaders(w http.ResponseWriter)
- func (h *ProxyHandler) Start() error
- func (h *ProxyHandler) Stop()
- type ResourcesWatcher
- type STDIOBridge
- type ServerInstance
- type Tool
Constants ¶
This section is empty.
Variables ¶
var ( StreamableHTTPConnections = make(map[string]*MCPStreamableHTTPConnection) StreamableHTTPConnectionsMutex sync.RWMutex )
StreamableHTTPConnections holds streamable HTTP connections
Functions ¶
This section is empty.
Types ¶
type ConnectionManager ¶
type ConnectionManager struct {
// contains filtered or unexported fields
}
ConnectionManager manages enhanced SSE connection lifecycle
func NewConnectionManager ¶
func NewConnectionManager(handler *ProxyHandler) *ConnectionManager
NewConnectionManager creates a new connection manager
func (*ConnectionManager) CleanupStaleConnections ¶
func (cm *ConnectionManager) CleanupStaleConnections(maxIdleTime time.Duration) int
CleanupStaleConnections removes connections that haven't been used recently
func (*ConnectionManager) GetAllConnectionStats ¶
func (cm *ConnectionManager) GetAllConnectionStats() map[string]*ConnectionMetrics
GetAllConnectionStats returns statistics for all connections
func (*ConnectionManager) GetConnectionStats ¶
func (cm *ConnectionManager) GetConnectionStats(serverName string) *ConnectionMetrics
GetConnectionStats returns detailed connection statistics
func (*ConnectionManager) GetConnectionSummary ¶
func (cm *ConnectionManager) GetConnectionSummary() map[string]interface{}
GetConnectionSummary returns a summary of all connection statuses
func (*ConnectionManager) GetHealthCheckResults ¶
func (cm *ConnectionManager) GetHealthCheckResults(maxResults int) []HealthCheckResult
GetHealthCheckResults returns recent health check results
func (*ConnectionManager) HealthCheck ¶
func (cm *ConnectionManager) HealthCheck(serverName string) HealthCheckResult
HealthCheck performs a health check on a specific connection
func (*ConnectionManager) PerformHealthChecks ¶
func (cm *ConnectionManager) PerformHealthChecks()
PerformHealthChecks runs health checks on all active connections
func (*ConnectionManager) RecordRequest ¶
func (cm *ConnectionManager) RecordRequest(serverName string, success bool, responseTime time.Duration)
RecordRequest records a request attempt and its outcome
func (*ConnectionManager) StartMonitoring ¶
func (cm *ConnectionManager) StartMonitoring(interval time.Duration)
StartMonitoring starts background monitoring of connections
type ConnectionMetrics ¶
type ConnectionMetrics struct {
ServerName string
ConnectionType string
TotalRequests int64
SuccessfulRequests int64
FailedRequests int64
AverageResponseTime time.Duration
LastResponseTime time.Duration
ConnectionUptime time.Duration
CreatedAt time.Time
LastUsed time.Time
ErrorRate float64
// contains filtered or unexported fields
}
ConnectionMetrics tracks detailed connection performance
type ConnectionStats ¶
type ConnectionStats struct {
TotalRequests int64
FailedRequests int64
TimeoutErrors int64
LastError time.Time
LastSuccess time.Time
// contains filtered or unexported fields
}
ConnectionStats tracks connection performance
type EnhancedMCPSSEConnection ¶
type EnhancedMCPSSEConnection struct {
ServerName string
BaseURL string
SSEEndpoint string
SessionEndpoint string
LastUsed time.Time
Initialized bool
Healthy bool
Capabilities map[string]interface{}
ServerInfo map[string]interface{}
SessionID string
// contains filtered or unexported fields
}
EnhancedMCPSSEConnection represents a high-performance Server-Sent Events connection to an MCP server
func (*EnhancedMCPSSEConnection) GetConnectionStats ¶
func (conn *EnhancedMCPSSEConnection) GetConnectionStats() map[string]interface{}
GetConnectionStats returns performance metrics for the connection
type HealthCheckResult ¶
type HealthCheckResult struct {
ServerName string
Healthy bool
ResponseTime time.Duration
Error error
CheckedAt time.Time
}
HealthCheckResult represents the result of a connection health check
type K8sManager ¶
type K8sManager struct {
// contains filtered or unexported fields
}
K8sManager handles system server lifecycle operations
func NewK8sManager ¶
func NewK8sManager(cfg *config.ComposeConfig, namespace string) (*K8sManager, error)
NewK8sManager creates a new system server manager
func (*K8sManager) GetServerStatus ¶
func (m *K8sManager) GetServerStatus(name string) (string, error)
GetServerStatus returns the status of a server
func (*K8sManager) ListServers ¶
func (m *K8sManager) ListServers() []string
ListServers returns a list of all configured servers
func (*K8sManager) Shutdown ¶
func (m *K8sManager) Shutdown() error
Shutdown gracefully shuts down the manager
func (*K8sManager) StartServer ¶
func (m *K8sManager) StartServer(name string) error
StartServer starts a server using Kubernetes MCPServer CRD
func (*K8sManager) StopServer ¶
func (m *K8sManager) StopServer(name string) error
StopServer stops a server by deleting the MCPServer CRD
type K8sServerInstance ¶
type K8sServerInstance struct {
Name string
Config config.ServerConfig
Status string
StartTime time.Time
// contains filtered or unexported fields
}
K8sServerInstance represents a system server instance
type MCPHTTPConnection ¶
type MCPHTTPConnection struct {
ServerName string
BaseURL string
LastUsed time.Time
Initialized bool
Healthy bool
Capabilities map[string]interface{}
ServerInfo map[string]interface{}
SessionID string
// contains filtered or unexported fields
}
MCPHTTPConnection represents a persistent HTTP connection to an MCP server
type MCPRequest ¶
type MCPRequest struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id"`
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
}
MCPRequest, MCPResponse, MCPError structs (standard JSON-RPC definitions)
type MCPResponse ¶
type MCPSSEConnection ¶
type MCPSSEConnection struct {
ServerName string
BaseURL string
SSEEndpoint string
SessionEndpoint string
LastUsed time.Time
Initialized bool
Healthy bool
Capabilities map[string]interface{}
ServerInfo map[string]interface{}
SessionID string
// contains filtered or unexported fields
}
MCPSSEConnection represents a Server-Sent Events connection to an MCP server
type MCPSTDIOConnection ¶
type MCPSTDIOConnection struct {
ServerName string
Host string
Port int
Connection net.Conn
Reader *bufio.Reader
Writer *bufio.Writer
LastUsed time.Time
Initialized bool
Healthy bool
// contains filtered or unexported fields
}
MCPSTDIOConnection represents a STDIO connection to an MCP server
type MCPStreamableHTTPConnection ¶
type MCPStreamableHTTPConnection struct {
ServerName string
BaseURL string
LastUsed time.Time
Initialized bool
Healthy bool
Capabilities map[string]interface{}
ServerInfo map[string]interface{}
SessionID string
// contains filtered or unexported fields
}
MCPStreamableHTTPConnection represents a streamable HTTP connection to an MCP server This is designed for clients like Gemini CLI that expect streaming HTTP responses
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles server lifecycle operations
func NewManager ¶
func NewManager(cfg *config.ComposeConfig) (*Manager, error)
func (*Manager) GetServerInstance ¶
func (m *Manager) GetServerInstance(serverName string) (*ServerInstance, bool)
func (*Manager) GetServerStatus ¶
GetServerStatus returns the status of a server, using the fixed identifier. This public method ensures locking.
func (*Manager) StartServer ¶
func (*Manager) StopServer ¶
StopServer stops a server using its fixed identifier
type ProxyHandler ¶
type ProxyHandler struct {
// Core K8s components
ServiceDiscovery *discovery.K8sServiceDiscovery
ConnectionManager *discovery.DynamicConnectionManager
Config *config.ComposeConfig
Logger *logging.Logger
// Existing functionality maintained
APIKey string
EnableAPI bool
ProxyStarted time.Time
GlobalRequestID int
GlobalIDMutex sync.Mutex
// Legacy connection management (for compatibility with existing API handlers)
ServerConnections map[string]*MCPHTTPConnection
SSEConnections map[string]*MCPSSEConnection
SSEMutex sync.RWMutex
StdioConnections map[string]*MCPSTDIOConnection
StdioMutex sync.RWMutex
Manager *Manager
// Enhanced SSE connections (for compatibility)
EnhancedSSEConnections map[string]*EnhancedMCPSSEConnection
EnhancedSSEMutex sync.RWMutex
ConnectionMutex sync.RWMutex
// contains filtered or unexported fields
}
ProxyHandler is a proxy handler
func NewProxyHandler ¶
func NewProxyHandler(cfg *config.ComposeConfig, namespace, apiKey string) (*ProxyHandler, error)
NewProxyHandler creates a new proxy handler
func (*ProxyHandler) CheckAuth ¶
func (h *ProxyHandler) CheckAuth(r *http.Request) bool
CheckAuth validates API key authentication (public method for cmd/proxy.go)
func (*ProxyHandler) CorsError ¶
func (h *ProxyHandler) CorsError(w http.ResponseWriter, message string, statusCode int)
CorsError writes a CORS-enabled error response (public method for cmd/proxy.go)
func (*ProxyHandler) DiscoverServerTools ¶
func (h *ProxyHandler) DiscoverServerTools(serverName string) ([]Tool, error)
DiscoverServerTools discovers tools from a specific server (public method for cmd/proxy.go)
func (*ProxyHandler) FindServerForTool ¶
func (h *ProxyHandler) FindServerForTool(toolName string) (string, bool)
FindServerForTool finds which server has a specific tool using cached discovery
func (*ProxyHandler) GetConnectionStatus ¶
func (h *ProxyHandler) GetConnectionStatus() map[string]discovery.ConnectionStatus
GetConnectionStatus returns the status of all connections
func (*ProxyHandler) GetDiscoveredServers ¶
func (h *ProxyHandler) GetDiscoveredServers() []discovery.ServiceEndpoint
GetDiscoveredServers returns information about discovered servers
func (*ProxyHandler) GetProxyInfo ¶
func (h *ProxyHandler) GetProxyInfo() map[string]interface{}
GetProxyInfo returns information about the proxy
func (*ProxyHandler) HandleDirectToolCall ¶
func (h *ProxyHandler) HandleDirectToolCall(w http.ResponseWriter, r *http.Request, toolName string)
HandleDirectToolCall handles direct tool calls without MCP protocol overhead
func (*ProxyHandler) HandleMCPRequest ¶
func (h *ProxyHandler) HandleMCPRequest(w http.ResponseWriter, r *http.Request, serverName string)
HandleMCPRequest handles MCP requests using discovered services
func (*ProxyHandler) RefreshConnections ¶
func (h *ProxyHandler) RefreshConnections() error
RefreshConnections triggers a refresh of service discovery and connections
func (*ProxyHandler) SendHTTPToolCall ¶
func (h *ProxyHandler) SendHTTPToolCall(conn *discovery.MCPConnection, request map[string]interface{}) (map[string]interface{}, error)
SendHTTPToolCall sends a tools/call request via HTTP (exported for proxy endpoints)
func (*ProxyHandler) SendSSEToolCall ¶
func (h *ProxyHandler) SendSSEToolCall(conn *discovery.MCPConnection, request map[string]interface{}) (map[string]interface{}, error)
SendSSEToolCall sends a tools/call request via SSE (exported for proxy endpoints)
func (*ProxyHandler) SendStreamableHTTPToolCall ¶
func (h *ProxyHandler) SendStreamableHTTPToolCall(serverName string, request map[string]interface{}) (map[string]interface{}, error)
SendStreamableHTTPToolCall sends a tools/call request via streamable HTTP
func (*ProxyHandler) ServeHTTP ¶
func (h *ProxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*ProxyHandler) SetCORSHeaders ¶
func (h *ProxyHandler) SetCORSHeaders(w http.ResponseWriter)
SetCORSHeaders sets CORS headers for cross-origin requests (public method for cmd/proxy.go)
func (*ProxyHandler) Start ¶
func (h *ProxyHandler) Start() error
Start begins the proxy handler operation
type ResourcesWatcher ¶
type ResourcesWatcher struct {
// contains filtered or unexported fields
}
func NewResourcesWatcher ¶
func NewResourcesWatcher(cfg *config.ServerConfig, instance *ServerInstance, loggerInstance ...*logging.Logger) (*ResourcesWatcher, error)
func (*ResourcesWatcher) Start ¶
func (w *ResourcesWatcher) Start()
func (*ResourcesWatcher) Stop ¶
func (w *ResourcesWatcher) Stop()
type STDIOBridge ¶
type STDIOBridge struct {
ProxyURL string
ServerName string
APIKey string
// contains filtered or unexported fields
}
STDIOBridge handles stdio communication for MCP hosts like Claude Desktop
func NewSTDIOBridge ¶
func NewSTDIOBridge(proxyURL, serverName, apiKey string, stdin io.Reader, stdout io.Writer) *STDIOBridge
NewSTDIOBridge creates a new stdio bridge
type ServerInstance ¶
type ServerInstance struct {
Name string
Config config.ServerConfig
ContainerID string
Process *runtime.Process
IsContainer bool
Status string
StartTime time.Time
Capabilities map[string]bool
ConnectionInfo map[string]string
HealthStatus string
ResourcesWatcher *ResourcesWatcher
ProgressManager *protocol.ProgressManager
ResourceManager *protocol.ResourceManager
SamplingManager *protocol.SamplingManager
// contains filtered or unexported fields
}
ServerInstance represents a running server instance
Source Files
¶
- api_handlers.go
- connection_manager.go
- direct_tool_calls.go
- http_connections.go
- http_router.go
- k8s_manager.go
- k8s_proxy.go
- manager.go
- notification_integration.go
- openapi_handlers.go
- sse_connections.go
- sse_connections_enhanced.go
- stdio_bridge.go
- stdio_connections.go
- streamable_http_connections.go
- tool_discovery.go
- utils.go