Documentation
¶
Overview ¶
Package config provides configuration types and merge utilities for MCPProxy. This file implements smart config patching with deep merge semantics. Related issues: #239, #240
Index ¶
- Constants
- Variables
- func BoolPtr(b bool) *bool
- func CreateSampleConfig(path string) error
- func DefaultCheckIntervals() []time.Duration
- func GetConfigPath(dataDir string) string
- func MergeMap(dst, src map[string]string) map[string]string
- func MergeMapWithOpts(dst, src map[string]string, mapField string, opts MergeOptions) map[string]string
- func MergeMapWithRemoval(dst, src map[string]string) map[string]string
- func MergeServerConfig(base, patch *ServerConfig, opts MergeOptions) (*ServerConfig, *ConfigDiff, error)
- func OAuthConfigChanged(old, new *OAuthConfig) bool
- func SaveConfig(cfg *Config, path string) error
- func SaveConfigToDataDir(cfg *Config) error
- func SetRegistriesInitCallback(callback func(*Config))
- func ValidateOAuthExtraParams(params map[string]string) error
- type APIKeySource
- type Config
- type ConfigDiff
- type CursorMCPConfig
- type CursorServerConfig
- type DockerIsolationConfig
- type DockerRecoveryConfig
- func (d *DockerRecoveryConfig) GetCheckIntervals() []time.Duration
- func (d *DockerRecoveryConfig) GetMaxRetries() int
- func (d *DockerRecoveryConfig) IsEnabled() bool
- func (d *DockerRecoveryConfig) ShouldNotifyOnFailure() bool
- func (d *DockerRecoveryConfig) ShouldNotifyOnRetry() bool
- func (d *DockerRecoveryConfig) ShouldNotifyOnStart() bool
- func (d *DockerRecoveryConfig) ShouldNotifyOnSuccess() bool
- func (d *DockerRecoveryConfig) ShouldPersistState() bool
- type Duration
- type FeatureFlags
- type FieldChange
- type ImmutableFieldError
- type IntentDeclarationConfig
- type IsolationConfig
- type LogConfig
- type MergeOptions
- type OAuthConfig
- type RegistryEntry
- type SearchResult
- type ServerConfig
- type TLSConfig
- type TokenizerConfig
- type ToolAnnotations
- type ToolMetadata
- type ToolRegistration
- type ToolStatEntry
- type ToolStats
- type ValidationError
Constants ¶
const ( DefaultDataDir = ".mcpproxy" ConfigFileName = "mcp_config.json" )
Variables ¶
var ( // ErrImmutableField is returned when attempting to modify an immutable field ErrImmutableField = errors.New("cannot modify immutable field") // ErrInvalidConfig is returned when merged config fails validation ErrInvalidConfig = errors.New("invalid configuration after merge") )
Error types for merge operations
Functions ¶
func BoolPtr ¶
BoolPtr returns a pointer to the given bool value. Useful for setting *bool fields in struct literals.
func CreateSampleConfig ¶
CreateSampleConfig creates a sample configuration file
func DefaultCheckIntervals ¶
DefaultCheckIntervals returns the default Docker recovery check intervals
func GetConfigPath ¶
GetConfigPath returns the path to the configuration file in the data directory
func MergeMap ¶
MergeMap deep merges src into dst, returning a new map. Empty string values in src do NOT remove keys (use explicit removal mechanism). The original maps are not modified.
func MergeMapWithOpts ¶
func MergeMapWithOpts(dst, src map[string]string, mapField string, opts MergeOptions) map[string]string
MergeMapWithOpts deep merges src into dst with RFC 7396 null-means-remove semantics. Keys marked for removal via opts.ShouldRemoveMapKey are deleted from the result. This implements proper JSON Merge Patch behavior where null values remove keys. The original maps are not modified.
func MergeMapWithRemoval ¶
MergeMapWithRemoval deep merges src into dst with support for key removal. Keys with empty string values in src will be removed from the result.
func MergeServerConfig ¶
func MergeServerConfig(base, patch *ServerConfig, opts MergeOptions) (*ServerConfig, *ConfigDiff, error)
MergeServerConfig deep merges patch into base, returning the merged config and diff.
Merge semantics:
- Scalar fields: Replace if patch value is non-zero
- Map fields (env, headers): Deep merge, null values remove keys
- Struct fields (isolation, oauth): Deep merge nested fields
- Array fields (args, extra_args, scopes): Replace entirely
- Nil/omitted fields in patch: Preserve base value
Returns:
- merged: The resulting merged configuration (new copy)
- diff: Changes made during merge (nil if opts.GenerateDiff is false)
- error: Validation or merge error
func OAuthConfigChanged ¶
func OAuthConfigChanged(old, new *OAuthConfig) bool
OAuthConfigChanged checks if OAuth configuration has changed between two configs. Returns true if any OAuth field differs (ClientID, Scopes, ExtraParams, etc.)
func SaveConfig ¶
SaveConfig saves configuration to file
func SaveConfigToDataDir ¶
SaveConfigToDataDir saves configuration to the data directory
func SetRegistriesInitCallback ¶
func SetRegistriesInitCallback(callback func(*Config))
SetRegistriesInitCallback sets the callback function for registries initialization
func ValidateOAuthExtraParams ¶
ValidateOAuthExtraParams validates that extra_params does not attempt to override reserved OAuth 2.0 parameters
Types ¶
type APIKeySource ¶
type APIKeySource int
APIKeySource represents where the API key came from
const ( APIKeySourceEnvironment APIKeySource = iota APIKeySourceConfig APIKeySourceGenerated )
func (APIKeySource) String ¶
func (s APIKeySource) String() string
String returns a human-readable representation of the API key source
type Config ¶
type Config struct {
Listen string `json:"listen" mapstructure:"listen"`
TrayEndpoint string `json:"tray_endpoint,omitempty" mapstructure:"tray-endpoint"` // Tray endpoint override (unix:// or npipe://)
EnableSocket bool `json:"enable_socket" mapstructure:"enable-socket"` // Enable Unix socket/named pipe for local IPC (default: true)
DataDir string `json:"data_dir" mapstructure:"data-dir"`
EnableTray bool `json:"enable_tray" mapstructure:"tray"`
DebugSearch bool `json:"debug_search" mapstructure:"debug-search"`
Servers []*ServerConfig `json:"mcpServers" mapstructure:"servers"`
TopK int `json:"top_k" mapstructure:"top-k"`
ToolsLimit int `json:"tools_limit" mapstructure:"tools-limit"`
ToolResponseLimit int `json:"tool_response_limit" mapstructure:"tool-response-limit"`
CallToolTimeout Duration `json:"call_tool_timeout" mapstructure:"call-tool-timeout" swaggertype:"string"`
// Environment configuration for secure variable filtering
Environment *secureenv.EnvConfig `json:"environment,omitempty" mapstructure:"environment"`
// Logging configuration
Logging *LogConfig `json:"logging,omitempty" mapstructure:"logging"`
// Security settings
APIKey string `json:"api_key,omitempty" mapstructure:"api-key"` // API key for REST API authentication
ReadOnlyMode bool `json:"read_only_mode" mapstructure:"read-only-mode"`
DisableManagement bool `json:"disable_management" mapstructure:"disable-management"`
AllowServerAdd bool `json:"allow_server_add" mapstructure:"allow-server-add"`
AllowServerRemove bool `json:"allow_server_remove" mapstructure:"allow-server-remove"`
// Prompts settings
EnablePrompts bool `json:"enable_prompts" mapstructure:"enable-prompts"`
// Repository detection settings
CheckServerRepo bool `json:"check_server_repo" mapstructure:"check-server-repo"`
// Docker isolation settings
DockerIsolation *DockerIsolationConfig `json:"docker_isolation,omitempty" mapstructure:"docker-isolation"`
// Docker recovery settings
DockerRecovery *DockerRecoveryConfig `json:"docker_recovery,omitempty" mapstructure:"docker-recovery"`
// Registries configuration for MCP server discovery
Registries []RegistryEntry `json:"registries,omitempty" mapstructure:"registries"`
// Feature flags for modular functionality
Features *FeatureFlags `json:"features,omitempty" mapstructure:"features"`
// TLS configuration
TLS *TLSConfig `json:"tls,omitempty" mapstructure:"tls"`
// Tokenizer configuration for token counting
Tokenizer *TokenizerConfig `json:"tokenizer,omitempty" mapstructure:"tokenizer"`
// Code execution settings
EnableCodeExecution bool `json:"enable_code_execution" mapstructure:"enable-code-execution"` // Enable JavaScript code execution tool (default: false)
CodeExecutionTimeoutMs int `json:"code_execution_timeout_ms,omitempty" mapstructure:"code-execution-timeout-ms"` // Timeout in milliseconds (default: 120000, max: 600000)
CodeExecutionMaxToolCalls int `json:"code_execution_max_tool_calls,omitempty" mapstructure:"code-execution-max-tool-calls"` // Max tool calls per execution (0 = unlimited, default: 0)
CodeExecutionPoolSize int `json:"code_execution_pool_size,omitempty" mapstructure:"code-execution-pool-size"` // JavaScript runtime pool size (default: 10)
// Health status settings
OAuthExpiryWarningHours float64 `json:"oauth_expiry_warning_hours,omitempty" mapstructure:"oauth-expiry-warning-hours"` // Hours before token expiry to show degraded status (default: 1.0)
// Activity logging settings (RFC-003)
ActivityRetentionDays int `json:"activity_retention_days,omitempty" mapstructure:"activity-retention-days"` // Max age before pruning (default: 90)
ActivityMaxRecords int `json:"activity_max_records,omitempty" mapstructure:"activity-max-records"` // Max records before pruning (default: 100000)
ActivityMaxResponseSize int `json:"activity_max_response_size,omitempty" mapstructure:"activity-max-response-size"` // Response truncation limit in bytes (default: 65536)
ActivityCleanupIntervalMin int `json:"activity_cleanup_interval_min,omitempty" mapstructure:"activity-cleanup-interval-min"` // Background cleanup interval in minutes (default: 60)
// Intent declaration settings (Spec 018)
IntentDeclaration *IntentDeclarationConfig `json:"intent_declaration,omitempty" mapstructure:"intent-declaration"`
// contains filtered or unexported fields
}
Config represents the main configuration structure
func LoadFromFile ¶
LoadFromFile loads configuration from a specific file
func LoadOrCreateConfig ¶
LoadOrCreateConfig loads configuration from the data directory or creates a new one
func (*Config) EnsureAPIKey ¶
func (c *Config) EnsureAPIKey() (apiKey string, wasGenerated bool, source APIKeySource)
EnsureAPIKey ensures the API key is set, generating one if needed Returns the API key, whether it was auto-generated, and the source SECURITY: Empty API keys are never allowed - always auto-generates if empty or missing
func (*Config) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface
func (*Config) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface
func (*Config) ValidateDetailed ¶
func (c *Config) ValidateDetailed() []ValidationError
ValidateDetailed performs detailed validation and returns all errors
type ConfigDiff ¶
type ConfigDiff struct {
// Modified fields with before/after values
Modified map[string]FieldChange `json:"modified,omitempty"`
// Fields that were added (didn't exist in base)
Added []string `json:"added,omitempty"`
// Fields that were removed (via null in patch)
Removed []string `json:"removed,omitempty"`
// Timestamp of the merge operation
Timestamp time.Time `json:"timestamp"`
}
ConfigDiff captures changes made during a merge operation for auditing
func (*ConfigDiff) IsEmpty ¶
func (d *ConfigDiff) IsEmpty() bool
IsEmpty returns true if no changes were made
type CursorMCPConfig ¶
type CursorMCPConfig struct {
MCPServers map[string]CursorServerConfig `json:"mcpServers"`
}
CursorMCPConfig represents the structure for Cursor IDE MCP configuration
type CursorServerConfig ¶
type CursorServerConfig struct {
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
}
CursorServerConfig represents a single server configuration in Cursor format
type DockerIsolationConfig ¶
type DockerIsolationConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"` // Global enable/disable for Docker isolation
DefaultImages map[string]string `json:"default_images" mapstructure:"default_images"` // Map of runtime type to Docker image
Registry string `json:"registry,omitempty" mapstructure:"registry"` // Custom registry (defaults to docker.io)
NetworkMode string `json:"network_mode,omitempty" mapstructure:"network_mode"` // Docker network mode (default: bridge)
MemoryLimit string `json:"memory_limit,omitempty" mapstructure:"memory_limit"` // Memory limit for containers
CPULimit string `json:"cpu_limit,omitempty" mapstructure:"cpu_limit"` // CPU limit for containers
Timeout Duration `json:"timeout,omitempty" mapstructure:"timeout" swaggertype:"string"` // Container startup timeout
ExtraArgs []string `json:"extra_args,omitempty" mapstructure:"extra_args"` // Additional docker run arguments
LogDriver string `json:"log_driver,omitempty" mapstructure:"log_driver"` // Docker log driver (default: json-file)
LogMaxSize string `json:"log_max_size,omitempty" mapstructure:"log_max_size"` // Maximum size of log files (default: 100m)
LogMaxFiles string `json:"log_max_files,omitempty" mapstructure:"log_max_files"` // Maximum number of log files (default: 3)
}
DockerIsolationConfig represents global Docker isolation settings
func DefaultDockerIsolationConfig ¶
func DefaultDockerIsolationConfig() *DockerIsolationConfig
DefaultDockerIsolationConfig returns default Docker isolation configuration
type DockerRecoveryConfig ¶
type DockerRecoveryConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"` // Enable Docker recovery monitoring (default: true)
CheckIntervals []Duration `json:"check_intervals,omitempty" mapstructure:"intervals" swaggerignore:"true"` // Custom health check intervals (exponential backoff)
MaxRetries int `json:"max_retries,omitempty" mapstructure:"max_retries"` // Maximum retry attempts (0 = unlimited)
NotifyOnStart bool `json:"notify_on_start" mapstructure:"notify_on_start"` // Show notification when recovery starts (default: true)
NotifyOnSuccess bool `json:"notify_on_success" mapstructure:"notify_on_success"` // Show notification on successful recovery (default: true)
NotifyOnFailure bool `json:"notify_on_failure" mapstructure:"notify_on_failure"` // Show notification on recovery failure (default: true)
NotifyOnRetry bool `json:"notify_on_retry" mapstructure:"notify_on_retry"` // Show notification on each retry (default: false)
PersistentState bool `json:"persistent_state" mapstructure:"persistent_state"` // Save recovery state across restarts (default: true)
}
DockerRecoveryConfig represents Docker recovery settings for the tray application
func (*DockerRecoveryConfig) GetCheckIntervals ¶
func (d *DockerRecoveryConfig) GetCheckIntervals() []time.Duration
GetCheckIntervals returns the configured check intervals as time.Duration slice, or defaults if not set
func (*DockerRecoveryConfig) GetMaxRetries ¶
func (d *DockerRecoveryConfig) GetMaxRetries() int
GetMaxRetries returns the maximum number of retries (0 = unlimited)
func (*DockerRecoveryConfig) IsEnabled ¶
func (d *DockerRecoveryConfig) IsEnabled() bool
IsEnabled returns whether Docker recovery is enabled (default: true)
func (*DockerRecoveryConfig) ShouldNotifyOnFailure ¶
func (d *DockerRecoveryConfig) ShouldNotifyOnFailure() bool
ShouldNotifyOnFailure returns whether to notify on recovery failure (default: true)
func (*DockerRecoveryConfig) ShouldNotifyOnRetry ¶
func (d *DockerRecoveryConfig) ShouldNotifyOnRetry() bool
ShouldNotifyOnRetry returns whether to notify on each retry (default: false)
func (*DockerRecoveryConfig) ShouldNotifyOnStart ¶
func (d *DockerRecoveryConfig) ShouldNotifyOnStart() bool
ShouldNotifyOnStart returns whether to notify when recovery starts (default: true)
func (*DockerRecoveryConfig) ShouldNotifyOnSuccess ¶
func (d *DockerRecoveryConfig) ShouldNotifyOnSuccess() bool
ShouldNotifyOnSuccess returns whether to notify on successful recovery (default: true)
func (*DockerRecoveryConfig) ShouldPersistState ¶
func (d *DockerRecoveryConfig) ShouldPersistState() bool
ShouldPersistState returns whether to persist recovery state across restarts (default: true)
type Duration ¶
Duration is a wrapper around time.Duration that can be marshaled to/from JSON. When serialized to JSON, it is represented as a string (e.g., "30s", "5m"). @swaggertype string
func (Duration) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface
type FeatureFlags ¶
type FeatureFlags struct {
// Runtime features
EnableRuntime bool `json:"enable_runtime" mapstructure:"enable_runtime"`
EnableEventBus bool `json:"enable_event_bus" mapstructure:"enable_event_bus"`
EnableSSE bool `json:"enable_sse" mapstructure:"enable_sse"`
// Observability features
EnableObservability bool `json:"enable_observability" mapstructure:"enable_observability"`
EnableHealthChecks bool `json:"enable_health_checks" mapstructure:"enable_health_checks"`
EnableMetrics bool `json:"enable_metrics" mapstructure:"enable_metrics"`
EnableTracing bool `json:"enable_tracing" mapstructure:"enable_tracing"`
// Security features
EnableOAuth bool `json:"enable_oauth" mapstructure:"enable_oauth"`
EnableQuarantine bool `json:"enable_quarantine" mapstructure:"enable_quarantine"`
EnableDockerIsolation bool `json:"enable_docker_isolation" mapstructure:"enable_docker_isolation"`
// Storage features
EnableSearch bool `json:"enable_search" mapstructure:"enable_search"`
EnableCaching bool `json:"enable_caching" mapstructure:"enable_caching"`
EnableAsyncStorage bool `json:"enable_async_storage" mapstructure:"enable_async_storage"`
// UI features
EnableWebUI bool `json:"enable_web_ui" mapstructure:"enable_web_ui"`
EnableTray bool `json:"enable_tray" mapstructure:"enable_tray"`
// Development features
EnableDebugLogging bool `json:"enable_debug_logging" mapstructure:"enable_debug_logging"`
EnableContractTests bool `json:"enable_contract_tests" mapstructure:"enable_contract_tests"`
}
FeatureFlags represents feature toggles for mcpproxy functionality
func DefaultFeatureFlags ¶
func DefaultFeatureFlags() FeatureFlags
DefaultFeatureFlags returns the default feature flag configuration
func (*FeatureFlags) IsFeatureEnabled ¶
func (ff *FeatureFlags) IsFeatureEnabled(feature string) bool
IsFeatureEnabled checks if a specific feature is enabled
func (*FeatureFlags) ValidateFeatureFlags ¶
func (ff *FeatureFlags) ValidateFeatureFlags() error
ValidateFeatureFlags validates feature flag dependencies
type FieldChange ¶
type FieldChange struct {
// Path to the field (e.g., "isolation.image")
Path string `json:"path"`
// Value before merge
From interface{} `json:"from"`
// Value after merge
To interface{} `json:"to"`
}
FieldChange represents a single field modification
type ImmutableFieldError ¶
type ImmutableFieldError struct {
Field string
}
ImmutableFieldError provides details about which immutable field was modified
func (*ImmutableFieldError) Error ¶
func (e *ImmutableFieldError) Error() string
func (*ImmutableFieldError) Unwrap ¶
func (e *ImmutableFieldError) Unwrap() error
type IntentDeclarationConfig ¶
type IntentDeclarationConfig struct {
// StrictServerValidation controls whether server annotation mismatches
// cause rejection (true) or just warnings (false).
// Default: true (reject mismatches)
StrictServerValidation bool `json:"strict_server_validation" mapstructure:"strict-server-validation"`
}
IntentDeclarationConfig controls intent validation behavior for tool calls
func DefaultIntentDeclarationConfig ¶
func DefaultIntentDeclarationConfig() *IntentDeclarationConfig
DefaultIntentDeclarationConfig returns the default intent declaration configuration
func (*IntentDeclarationConfig) IsStrictServerValidation ¶
func (c *IntentDeclarationConfig) IsStrictServerValidation() bool
IsStrictServerValidation returns whether strict server validation is enabled
type IsolationConfig ¶
type IsolationConfig struct {
Enabled *bool `json:"enabled,omitempty" mapstructure:"enabled"` // Enable Docker isolation for this server (nil = inherit global)
Image string `json:"image,omitempty" mapstructure:"image"` // Custom Docker image (overrides default)
NetworkMode string `json:"network_mode,omitempty" mapstructure:"network_mode"` // Custom network mode for this server
ExtraArgs []string `json:"extra_args,omitempty" mapstructure:"extra_args"` // Additional docker run arguments for this server
WorkingDir string `json:"working_dir,omitempty" mapstructure:"working_dir"` // Custom working directory in container
LogDriver string `json:"log_driver,omitempty" mapstructure:"log_driver"` // Docker log driver override for this server
LogMaxSize string `json:"log_max_size,omitempty" mapstructure:"log_max_size"` // Maximum size of log files override
LogMaxFiles string `json:"log_max_files,omitempty" mapstructure:"log_max_files"` // Maximum number of log files override
}
IsolationConfig represents per-server isolation settings
func MergeIsolationConfig ¶
func MergeIsolationConfig(base, patch *IsolationConfig, removeIfNil bool) *IsolationConfig
MergeIsolationConfig deep merges patch into base isolation config. Returns nil if both are nil, or if removeIfNil is true and patch is nil.
func (*IsolationConfig) IsEnabled ¶
func (ic *IsolationConfig) IsEnabled() bool
IsEnabled returns true if isolation is explicitly enabled, false otherwise. Returns false if Enabled is nil (not set).
type LogConfig ¶
type LogConfig struct {
Level string `json:"level" mapstructure:"level"`
EnableFile bool `json:"enable_file" mapstructure:"enable-file"`
EnableConsole bool `json:"enable_console" mapstructure:"enable-console"`
Filename string `json:"filename" mapstructure:"filename"`
LogDir string `json:"log_dir,omitempty" mapstructure:"log-dir"` // Custom log directory
MaxSize int `json:"max_size" mapstructure:"max-size"` // MB
MaxBackups int `json:"max_backups" mapstructure:"max-backups"` // number of backup files
MaxAge int `json:"max_age" mapstructure:"max-age"` // days
Compress bool `json:"compress" mapstructure:"compress"`
JSONFormat bool `json:"json_format" mapstructure:"json-format"`
}
LogConfig represents logging configuration
type MergeOptions ¶
type MergeOptions struct {
// GenerateDiff controls whether to compute changes for audit trail
GenerateDiff bool
// NullRemovesField controls whether nil pointer in patch removes the field
// Default: true (RFC 7396 semantics)
NullRemovesField bool
// ImmutableFields lists fields that cannot be changed via merge
// Default: ["name", "created"]
ImmutableFields []string
// contains filtered or unexported fields
}
MergeOptions controls merge behavior
func DefaultMergeOptions ¶
func DefaultMergeOptions() MergeOptions
DefaultMergeOptions returns standard merge options
func (MergeOptions) GetRemoveMarkersForMap ¶
func (o MergeOptions) GetRemoveMarkersForMap(mapField string) []string
GetRemoveMarkersForMap returns all keys that should be removed from a map field
func (MergeOptions) ShouldRemove ¶
func (o MergeOptions) ShouldRemove(field string) bool
ShouldRemove checks if a field should be removed
func (MergeOptions) ShouldRemoveMapKey ¶
func (o MergeOptions) ShouldRemoveMapKey(mapField, key string) bool
ShouldRemoveMapKey checks if a specific key within a map field should be removed e.g., ShouldRemoveMapKey("env", "API_KEY") checks for "env.API_KEY" marker
func (MergeOptions) WithRemoveMarker ¶
func (o MergeOptions) WithRemoveMarker(field string) MergeOptions
WithRemoveMarker adds a field to the remove markers (used for explicit null handling)
type OAuthConfig ¶
type OAuthConfig struct {
ClientID string `json:"client_id,omitempty" mapstructure:"client_id"`
ClientSecret string `json:"client_secret,omitempty" mapstructure:"client_secret"`
RedirectURI string `json:"redirect_uri,omitempty" mapstructure:"redirect_uri"`
Scopes []string `json:"scopes,omitempty" mapstructure:"scopes"`
PKCEEnabled bool `json:"pkce_enabled,omitempty" mapstructure:"pkce_enabled"`
ExtraParams map[string]string `json:"extra_params,omitempty" mapstructure:"extra_params"` // Additional OAuth parameters (e.g., RFC 8707 resource)
}
OAuthConfig represents OAuth configuration for a server
func MergeOAuthConfig ¶
func MergeOAuthConfig(base, patch *OAuthConfig, removeIfNil bool) *OAuthConfig
MergeOAuthConfig deep merges patch into base OAuth config. Returns nil if both are nil, or if removeIfNil is true and patch is nil.
func (*OAuthConfig) Validate ¶
func (o *OAuthConfig) Validate() error
Validate performs validation on OAuthConfig
type RegistryEntry ¶
type RegistryEntry struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
URL string `json:"url"`
ServersURL string `json:"servers_url,omitempty"`
Tags []string `json:"tags,omitempty"`
Protocol string `json:"protocol,omitempty"`
Count interface{} `json:"count,omitempty" swaggertype:"primitive,string"` // number or string
}
RegistryEntry represents a registry in the configuration
type SearchResult ¶
type SearchResult struct {
Tool *ToolMetadata `json:"tool"`
Score float64 `json:"score"`
}
SearchResult represents a search result with score
type ServerConfig ¶
type ServerConfig struct {
Name string `json:"name,omitempty" mapstructure:"name"`
URL string `json:"url,omitempty" mapstructure:"url"`
Protocol string `json:"protocol,omitempty" mapstructure:"protocol"` // stdio, http, sse, streamable-http, auto
Command string `json:"command,omitempty" mapstructure:"command"`
Args []string `json:"args,omitempty" mapstructure:"args"`
WorkingDir string `json:"working_dir,omitempty" mapstructure:"working_dir"` // Working directory for stdio servers
Env map[string]string `json:"env,omitempty" mapstructure:"env"`
Headers map[string]string `json:"headers,omitempty" mapstructure:"headers"` // For HTTP servers
OAuth *OAuthConfig `json:"oauth" mapstructure:"oauth"` // OAuth configuration (keep even when empty to signal OAuth requirement)
Enabled bool `json:"enabled" mapstructure:"enabled"`
Quarantined bool `json:"quarantined" mapstructure:"quarantined"` // Security quarantine status
Created time.Time `json:"created" mapstructure:"created"`
Updated time.Time `json:"updated,omitempty" mapstructure:"updated"`
Isolation *IsolationConfig `json:"isolation,omitempty" mapstructure:"isolation"` // Per-server isolation settings
}
ServerConfig represents upstream MCP server configuration
func ConvertFromCursorFormat ¶
func ConvertFromCursorFormat(cursorConfig *CursorMCPConfig) []*ServerConfig
ConvertFromCursorFormat converts Cursor IDE format to our internal format
type TLSConfig ¶
type TLSConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"` // Enable HTTPS
RequireClientCert bool `json:"require_client_cert" mapstructure:"require_client_cert"` // Enable mTLS
CertsDir string `json:"certs_dir,omitempty" mapstructure:"certs_dir"` // Directory for certificates
HSTS bool `json:"hsts" mapstructure:"hsts"` // Enable HTTP Strict Transport Security
}
TLSConfig represents TLS configuration
type TokenizerConfig ¶
type TokenizerConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"` // Enable token counting
DefaultModel string `json:"default_model" mapstructure:"default_model"` // Default model for tokenization (e.g., "gpt-4")
Encoding string `json:"encoding" mapstructure:"encoding"` // Default encoding (e.g., "cl100k_base")
}
TokenizerConfig represents tokenizer configuration for token counting
type ToolAnnotations ¶
type ToolAnnotations struct {
Title string `json:"title,omitempty"`
ReadOnlyHint *bool `json:"readOnlyHint,omitempty"`
DestructiveHint *bool `json:"destructiveHint,omitempty"`
IdempotentHint *bool `json:"idempotentHint,omitempty"`
OpenWorldHint *bool `json:"openWorldHint,omitempty"`
}
ToolAnnotations represents MCP tool behavior hints
type ToolMetadata ¶
type ToolMetadata struct {
Name string `json:"name"`
ServerName string `json:"server_name"`
Description string `json:"description"`
ParamsJSON string `json:"params_json"`
Hash string `json:"hash"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
Annotations *ToolAnnotations `json:"annotations,omitempty"`
}
ToolMetadata represents tool information stored in the index
type ToolRegistration ¶
type ToolRegistration struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]interface{} `json:"input_schema"`
ServerName string `json:"server_name"`
OriginalName string `json:"original_name"`
}
ToolRegistration represents a tool registration
type ToolStatEntry ¶
ToolStatEntry represents a single tool stat entry
type ToolStats ¶
type ToolStats struct {
TotalTools int `json:"total_tools"`
TopTools []ToolStatEntry `json:"top_tools"`
}
ToolStats represents tool statistics
type ValidationError ¶
ValidationError represents a configuration validation error
func (ValidationError) Error ¶
func (v ValidationError) Error() string
Error implements the error interface