Documentation
¶
Index ¶
- func ExtractToken(r *http.Request) string
- func GetBuildVersion() string
- func GetEdition() string
- func GetLogger(ctx context.Context) *zap.SugaredLogger
- func RequestIDLoggerMiddleware(logger *zap.SugaredLogger) func(http.Handler) http.Handler
- func RequestIDMiddleware(next http.Handler) http.Handler
- func SetEdition(edition string)
- func SetupSwaggerHandler(logger *zap.SugaredLogger) http.Handler
- func WithLogger(ctx context.Context, logger *zap.SugaredLogger) context.Context
- type AddServerRequest
- type CanonicalConfigPath
- type CanonicalConfigPathsResponse
- type CodeExecError
- type CodeExecHandler
- type CodeExecOptions
- type CodeExecRequest
- type CodeExecResponse
- type ConnectRequest
- type FeedbackSubmitter
- type ImportFromPathRequest
- type ImportRequest
- type ImportResponse
- type ImportedServerResponse
- type Server
- type ServerController
- type ServerNameLister
- type TokenStore
- type ToolCaller
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractToken ¶ added in v0.20.0
ExtractToken extracts the authentication token from the request. It checks (in order): X-API-Key header, Authorization: Bearer header, ?apikey= query param. Returns an empty string if no token is found.
func GetBuildVersion ¶
func GetBuildVersion() string
GetBuildVersion returns the build version from build-time variables. This should be set during build using -ldflags.
func GetLogger ¶
func GetLogger(ctx context.Context) *zap.SugaredLogger
GetLogger retrieves the logger from context, or returns a nop logger if not found
func RequestIDLoggerMiddleware ¶
RequestIDLoggerMiddleware creates a logger with the request ID field and adds it to context. This middleware should be registered AFTER RequestIDMiddleware.
func RequestIDMiddleware ¶
RequestIDMiddleware extracts or generates a request ID for each request. If the client provides a valid X-Request-Id header, it is used. Otherwise, a new UUID v4 is generated. The request ID is: - Added to the request context - Set in the response header (before calling next handler) - Available for logging via GetRequestID(ctx)
func SetEdition ¶ added in v0.20.2
func SetEdition(edition string)
SetEdition sets the edition value (called from main during startup).
func SetupSwaggerHandler ¶
func SetupSwaggerHandler(logger *zap.SugaredLogger) http.Handler
SetupSwaggerHandler returns a handler for Swagger UI This is exported so it can be mounted on the main mux
func WithLogger ¶
WithLogger adds a logger to the context
Types ¶
type AddServerRequest ¶
type AddServerRequest struct {
Name string `json:"name"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
Protocol string `json:"protocol,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Quarantined *bool `json:"quarantined,omitempty"`
ReconnectOnUse *bool `json:"reconnect_on_use,omitempty"`
}
AddServerRequest represents a request to add a new server
type CanonicalConfigPath ¶ added in v0.15.1
type CanonicalConfigPath struct {
Name string `json:"name"` // Display name (e.g., "Claude Desktop")
Format string `json:"format"` // Format identifier (e.g., "claude_desktop")
Path string `json:"path"` // Full path to the config file
Exists bool `json:"exists"` // Whether the file exists
OS string `json:"os"` // Operating system (darwin, windows, linux)
Description string `json:"description"` // Brief description
}
CanonicalConfigPath represents a well-known config file path
type CanonicalConfigPathsResponse ¶ added in v0.15.1
type CanonicalConfigPathsResponse struct {
OS string `json:"os"` // Current operating system
Paths []CanonicalConfigPath `json:"paths"` // List of canonical config paths
}
CanonicalConfigPathsResponse represents the response for canonical config paths
type CodeExecError ¶
CodeExecError represents execution error details.
type CodeExecHandler ¶
type CodeExecHandler struct {
// contains filtered or unexported fields
}
CodeExecHandler handles POST /api/v1/code/exec requests.
func NewCodeExecHandler ¶
func NewCodeExecHandler(toolCaller ToolCaller, logger *zap.SugaredLogger) *CodeExecHandler
NewCodeExecHandler creates a new code execution handler.
func (*CodeExecHandler) ServeHTTP ¶
func (h *CodeExecHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type CodeExecOptions ¶
type CodeExecOptions struct {
TimeoutMS int `json:"timeout_ms"`
MaxToolCalls int `json:"max_tool_calls"`
AllowedServers []string `json:"allowed_servers"`
}
CodeExecOptions represents execution options.
type CodeExecRequest ¶
type CodeExecRequest struct {
Code string `json:"code"`
Language string `json:"language,omitempty"` // "javascript" (default) or "typescript"
Input map[string]interface{} `json:"input"`
Options CodeExecOptions `json:"options"`
}
CodeExecRequest represents the request body for code execution.
type CodeExecResponse ¶
type CodeExecResponse struct {
OK bool `json:"ok"`
Result interface{} `json:"result,omitempty"`
Error *CodeExecError `json:"error,omitempty"`
Stats map[string]interface{} `json:"stats,omitempty"`
RequestID string `json:"request_id,omitempty"` // T016: Added for error correlation
}
CodeExecResponse represents the response format.
type ConnectRequest ¶ added in v0.23.0
type ConnectRequest struct {
ServerName string `json:"server_name,omitempty"` // Defaults to "mcpproxy"
Force bool `json:"force,omitempty"` // Overwrite existing entry
}
ConnectRequest is the optional JSON body for POST /api/v1/connect/{client}.
type FeedbackSubmitter ¶ added in v0.22.0
type FeedbackSubmitter interface {
SubmitFeedback(ctx context.Context, req *telemetry.FeedbackRequest) (*telemetry.FeedbackResponse, error)
}
FeedbackSubmitter is the interface needed for feedback submission. This decouples the HTTP handler from the telemetry package.
type ImportFromPathRequest ¶ added in v0.15.1
type ImportFromPathRequest struct {
Path string `json:"path"` // File path to import from
Format string `json:"format,omitempty"` // Optional format hint
ServerNames []string `json:"server_names,omitempty"` // Optional: import only these servers
}
ImportFromPathRequest represents a request to import from a file path
type ImportRequest ¶ added in v0.15.0
type ImportRequest struct {
Content string `json:"content"` // Raw JSON or TOML content
Format string `json:"format,omitempty"` // Optional format hint
ServerNames []string `json:"server_names,omitempty"` // Optional: import only these servers
}
ImportRequest represents a request to import servers from JSON/TOML content
type ImportResponse ¶ added in v0.15.0
type ImportResponse struct {
Format string `json:"format"`
FormatName string `json:"format_name"`
Summary configimport.ImportSummary `json:"summary"`
Imported []ImportedServerResponse `json:"imported"`
Skipped []configimport.SkippedServer `json:"skipped"`
Failed []configimport.FailedServer `json:"failed"`
Warnings []string `json:"warnings"`
}
ImportResponse represents the response from an import operation
type ImportedServerResponse ¶ added in v0.15.0
type ImportedServerResponse struct {
Name string `json:"name"`
Protocol string `json:"protocol"`
URL string `json:"url,omitempty"`
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
SourceFormat string `json:"source_format"`
OriginalName string `json:"original_name"`
FieldsSkipped []string `json:"fields_skipped,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
ImportedServerResponse represents an imported server in the response
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides HTTP API endpoints with chi router
func NewServer ¶
func NewServer(controller ServerController, logger *zap.SugaredLogger, obs *observability.Manager) *Server
NewServer creates a new HTTP API server
func (*Server) Router ¶ added in v0.21.0
Router returns the underlying chi.Mux for external route registration. This is used by the server edition to mount OAuth routes outside the default API key authentication group.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler
func (*Server) SetConnectService ¶ added in v0.23.0
SetConnectService configures the client connect/disconnect service.
func (*Server) SetFeedbackSubmitter ¶ added in v0.22.0
func (s *Server) SetFeedbackSubmitter(submitter FeedbackSubmitter)
SetFeedbackSubmitter configures the feedback submission handler (Spec 036).
func (*Server) SetTokenStore ¶ added in v0.20.0
func (s *Server) SetTokenStore(store TokenStore, dataDir string)
SetTokenStore configures agent token management on the server. This must be called after NewServer and before serving requests to enable the /api/v1/tokens endpoints.
type ServerController ¶
type ServerController interface {
IsRunning() bool
IsReady() bool
GetListenAddress() string
GetUpstreamStats() map[string]interface{}
StartServer(ctx context.Context) error
StopServer() error
GetStatus() interface{}
StatusChannel() <-chan interface{}
EventsChannel() <-chan internalRuntime.Event
// SubscribeEvents creates a new per-client event subscription channel.
// Each SSE client should get its own channel to avoid competing for events.
SubscribeEvents() chan internalRuntime.Event
// UnsubscribeEvents closes and removes the subscription channel.
UnsubscribeEvents(chan internalRuntime.Event)
// Server management
GetAllServers() ([]map[string]interface{}, error)
AddServer(ctx context.Context, serverConfig *config.ServerConfig) error // T001: Add server
RemoveServer(ctx context.Context, serverName string) error // T002: Remove server
UpdateServer(ctx context.Context, serverName string, updates *config.ServerConfig) error
EnableServer(serverName string, enabled bool) error
GetToolApprovalStatus(serverName, toolName string) (string, error)
RestartServer(serverName string) error
ForceReconnectAllServers(reason string) error
GetDockerRecoveryStatus() *storage.DockerRecoveryState
QuarantineServer(serverName string, quarantined bool) error
GetQuarantinedServers() ([]map[string]interface{}, error)
UnquarantineServer(serverName string) error
GetManagementService() interface{} // Returns the management service for unified operations
DiscoverServerTools(ctx context.Context, serverName string) error
// Tools and search
GetServerTools(serverName string) ([]map[string]interface{}, error)
SearchTools(query string, limit int) ([]map[string]interface{}, error)
// Logs
GetServerLogs(serverName string, tail int) ([]contracts.LogEntry, error)
// Config and OAuth
ReloadConfiguration() error
GetConfigPath() string
GetLogDir() string
TriggerOAuthLogin(serverName string) error
// Secrets management
GetSecretResolver() *secret.Resolver
GetCurrentConfig() interface{}
NotifySecretsChanged(ctx context.Context, operation, secretName string) error
// Tool call history
GetToolCalls(limit, offset int) ([]*contracts.ToolCallRecord, int, error)
GetToolCallByID(id string) (*contracts.ToolCallRecord, error)
GetServerToolCalls(serverName string, limit int) ([]*contracts.ToolCallRecord, error)
ReplayToolCall(id string, arguments map[string]interface{}) (*contracts.ToolCallRecord, error)
GetToolCallsBySession(sessionID string, limit, offset int) ([]*contracts.ToolCallRecord, int, error)
// Session management
GetRecentSessions(limit int) ([]*contracts.MCPSession, int, error)
GetSessionByID(sessionID string) (*contracts.MCPSession, error)
// Configuration management
ValidateConfig(cfg *config.Config) ([]config.ValidationError, error)
ApplyConfig(cfg *config.Config, cfgPath string) (*internalRuntime.ConfigApplyResult, error)
GetConfig() (*config.Config, error)
// Token statistics
GetTokenSavings() (*contracts.ServerTokenMetrics, error)
// Tool execution
CallTool(ctx context.Context, toolName string, arguments map[string]interface{}) (interface{}, error)
// Registry browsing (Phase 7)
ListRegistries() ([]interface{}, error)
SearchRegistryServers(registryID, tag, query string, limit int) ([]interface{}, error)
// Version and updates
GetVersionInfo() *updatecheck.VersionInfo
RefreshVersionInfo() *updatecheck.VersionInfo
// Activity logging (RFC-003)
ListActivities(filter storage.ActivityFilter) ([]*storage.ActivityRecord, int, error)
GetActivity(id string) (*storage.ActivityRecord, error)
StreamActivities(filter storage.ActivityFilter) <-chan *storage.ActivityRecord
// Tool-level quarantine (Spec 032)
ListToolApprovals(serverName string) ([]*storage.ToolApprovalRecord, error)
ApproveTools(serverName string, toolNames []string, approvedBy string) error
ApproveAllTools(serverName string, approvedBy string) (int, error)
GetToolApproval(serverName, toolName string) (*storage.ToolApprovalRecord, error)
}
ServerController defines the interface for core server functionality
type ServerNameLister ¶ added in v0.20.0
ServerNameLister provides the list of known server names for allowed_servers validation.
type TokenStore ¶ added in v0.20.0
type TokenStore interface {
CreateAgentToken(token auth.AgentToken, rawToken string, hmacKey []byte) error
ListAgentTokens() ([]auth.AgentToken, error)
GetAgentTokenByName(name string) (*auth.AgentToken, error)
RevokeAgentToken(name string) error
RegenerateAgentToken(name string, newRawToken string, hmacKey []byte) (*auth.AgentToken, error)
ValidateAgentToken(rawToken string, hmacKey []byte) (*auth.AgentToken, error)
UpdateAgentTokenLastUsed(name string) error
}
TokenStore defines the storage interface for agent token CRUD operations. This interface is satisfied by *storage.Manager.