Documentation
¶
Index ¶
- Constants
- Variables
- func GetPromptDefinitions() []types.PromptDefinition
- type AsyncStagingManager
- func (asm *AsyncStagingManager) BatchCreateStages(stages []*models.Stage) []error
- func (asm *AsyncStagingManager) Close()
- func (asm *AsyncStagingManager) CreateStageAsync(stage *models.Stage) <-chan error
- func (asm *AsyncStagingManager) CreateStageAsyncWithContext(ctx context.Context, stage *models.Stage) <-chan error
- type AtomicWriteHandle
- type BaseRegistry
- type Config
- type Error
- type ErrorObject
- type FileIntegrityCheck
- type FileLock
- type LogData
- type LogLevel
- type LogMessage
- type MCPError
- type MCPMetrics
- type Meta
- type Notification
- type NotificationHandler
- type NotificationMessage
- type PromptContent
- type PromptMessage
- type PromptRegistry
- type Registry
- type Request
- type RequestHandler
- type RequestMessage
- type ResourceContent
- type ResourceRegistry
- type ResourceTemplateRegistry
- type Response
- type ResponseMessage
- type Router
- func (r *Router) DispatchNotification(ctx context.Context, msg NotificationMessage) error
- func (r *Router) DispatchRequest(ctx context.Context, msg RequestMessage) ResponseMessage
- func (r *Router) RegisterNotification(method string, handler NotificationHandler)
- func (r *Router) RegisterRequest(method string, handler RequestHandler)
- type SafetyConfig
- type SafetyFile
- type SafetyManager
- func (sm *SafetyManager) AtomicWrite(path, content string) (*AtomicWriteHandle, error)
- func (sm *SafetyManager) LockFile(path string) (*FileLock, error)
- func (sm *SafetyManager) ReleaseLock(path string) error
- func (sm *SafetyManager) ValidateFileIntegrity(files []FileIntegrityCheck) error
- func (sm *SafetyManager) ValidateOperation(op *SafetyOperation) error
- type SafetyOperation
- type ServerInterface
- type SessionState
- func (s *SessionState) AppendElicitationRecord(params map[string]any, result map[string]any)
- func (s *SessionState) AppendSamplingRecord(params map[string]any, result map[string]any)
- func (s *SessionState) ClientCapabilities() map[string]any
- func (s *SessionState) ClientRoots() []string
- func (s *SessionState) ElicitationHistory() []types.ElicitationRecord
- func (s *SessionState) Initialized() bool
- func (s *SessionState) LoggingLevel() LogLevel
- func (s *SessionState) MarkInitialized(protocolVersion string, capabilities map[string]any)
- func (s *SessionState) ProtocolVersion() string
- func (s *SessionState) SamplingHistory() []types.SamplingRecord
- func (s *SessionState) SetClientRoots(roots []string)
- func (s *SessionState) SetLoggingLevel(level LogLevel)
- type StagingManager
- func (sm *StagingManager) ApplyStage(ctx context.Context, stageID string, autoApplied bool) (*models.Apply, error)
- func (sm *StagingManager) CleanupExpiredStages() error
- func (sm *StagingManager) CreateStage(ctx context.Context, stage *models.Stage) error
- func (sm *StagingManager) DeleteAppliedStages(sessionID string) error
- func (sm *StagingManager) DeleteStage(stageID string) error
- func (sm *StagingManager) GetStage(id string) (*models.Stage, error)
- func (sm *StagingManager) IsEnabled() bool
- func (sm *StagingManager) ListPendingStages(sessionID string) ([]models.Stage, error)
- type StdioServer
- func (s *StdioServer) Close() error
- func (s *StdioServer) ConfirmApply(ctx context.Context, summary string) error
- func (s *StdioServer) FinalizeTransform(ctx context.Context, req types.TransformRequest) (map[string]any, error)
- func (s *StdioServer) GetFileProcessor() *core.FileProcessor
- func (s *StdioServer) GetProviders() *providers.Registry
- func (s *StdioServer) GetSafety() any
- func (s *StdioServer) GetSessionID() string
- func (s *StdioServer) GetStaging() any
- func (s *StdioServer) LogDebug(message string, data ...LogData)
- func (s *StdioServer) LogError(message string, data ...LogData)
- func (s *StdioServer) LogInfo(message string, data ...LogData)
- func (s *StdioServer) LogWarning(message string, data ...LogData)
- func (s *StdioServer) Metrics() MCPMetrics
- func (s *StdioServer) RegisterResource(resource types.Resource)
- func (s *StdioServer) RegisterTool(name string, handler types.ToolHandler)
- func (s *StdioServer) ReportProgress(ctx context.Context, progress, total float64, message string)
- func (s *StdioServer) RequestElicitation(ctx context.Context, params map[string]any) (map[string]any, error)
- func (s *StdioServer) RequestRoots(ctx context.Context, params any, meta Meta) (ResponseMessage, error)
- func (s *StdioServer) RequestSampling(ctx context.Context, params map[string]any) (map[string]any, error)
- func (s *StdioServer) RequestSamplingMessage(ctx context.Context, params any, meta Meta) (ResponseMessage, error)
- func (s *StdioServer) ResourceDefinitions() []types.ResourceDefinition
- func (s *StdioServer) Start() error
- type ToolRegistry
- type Transaction
- type TransactionLog
- func (tl *TransactionLog) BeginTransaction(targetPath, tmpPath, backupPath string) string
- func (tl *TransactionLog) CompleteTransaction(txID string)
- func (tl *TransactionLog) FailTransaction(txID string, reason error) error
- func (tl *TransactionLog) GetPendingTransactions() []*Transaction
- func (tl *TransactionLog) GetSummary() TransactionSummary
- func (tl *TransactionLog) RollbackAll() error
- func (tl *TransactionLog) RollbackTransaction(txID string) error
- type TransactionSummary
Constants ¶
const ( // JSON-RPC 2.0 standard error codes ParseError = -32700 // Invalid JSON was received InvalidRequest = -32600 // The JSON sent is not a valid Request object MethodNotFound = -32601 // The method does not exist InvalidParams = -32602 // Invalid method parameters InternalError = -32603 // Internal JSON-RPC error // Custom domain error codes (10xxx range) LanguageNotFound = 10001 // No provider for the specified language SyntaxError = 10002 // Source code parsing failed NoMatches = 10003 // Query returned no results TransformFailed = 10004 // Transformation operation failed StageNotFound = 10005 // Staging ID doesn't exist StageExpired = 10006 // Staging has expired AlreadyApplied = 10007 // Stage was already applied DatabaseError = 10008 // Database operation failed ConfidenceTooLow = 10009 // Confidence below threshold ValidationFailed = 10010 // Code validation failed FileSystemError = 10011 // File system operation failed // Safety error codes (11xxx range) SafetyViolation = 11001 // General safety violation FileTooLarge = 11002 // File exceeds size limit TooManyFiles = 11003 // Too many files in operation TotalSizeTooLarge = 11004 // Total operation size too large FileModified = 11005 // File was modified externally FileLocked = 11006 // File is locked by another process LockTimeout = 11007 // Could not acquire file lock AtomicWriteFailed = 11008 // Atomic write operation failed BackupFailed = 11009 // Backup creation failed RollbackFailed = 11010 // Rollback operation failed PerFileConfidenceLow = 11011 // Individual file confidence too low )
Error codes following JSON-RPC 2.0 standard and custom domain errors
const JSONRPCVersion = "2.0"
JSON-RPC protocol constants used by the MCP transport layer.
Variables ¶
var ErrToolNotFound = errors.New("tool not found")
ErrToolNotFound indicates that a requested tool is not registered.
Functions ¶
func GetPromptDefinitions ¶ added in v1.2.0
func GetPromptDefinitions() []types.PromptDefinition
Types ¶
type AsyncStagingManager ¶
type AsyncStagingManager struct {
*StagingManager
// contains filtered or unexported fields
}
AsyncStagingManager handles staging with goroutine pool
func NewAsyncStagingManager ¶
func NewAsyncStagingManager(db *gorm.DB, config Config, safety *SafetyManager) *AsyncStagingManager
NewAsyncStagingManager creates concurrent staging manager
func (*AsyncStagingManager) BatchCreateStages ¶
func (asm *AsyncStagingManager) BatchCreateStages(stages []*models.Stage) []error
BatchCreateStages creates multiple stages concurrently
func (*AsyncStagingManager) Close ¶
func (asm *AsyncStagingManager) Close()
Close shuts down worker pool
func (*AsyncStagingManager) CreateStageAsync ¶
func (asm *AsyncStagingManager) CreateStageAsync(stage *models.Stage) <-chan error
func (*AsyncStagingManager) CreateStageAsyncWithContext ¶ added in v1.5.0
func (asm *AsyncStagingManager) CreateStageAsyncWithContext(ctx context.Context, stage *models.Stage) <-chan error
CreateStageAsyncWithContext stages transformation without blocking, honoring cancellation.
type AtomicWriteHandle ¶ added in v1.5.0
type AtomicWriteHandle struct {
// contains filtered or unexported fields
}
AtomicWriteHandle allows callers to finalize or revert a logged atomic write.
func (*AtomicWriteHandle) Commit ¶ added in v1.5.0
func (h *AtomicWriteHandle) Commit()
Commit marks the associated transaction as completed.
func (*AtomicWriteHandle) Rollback ¶ added in v1.5.0
func (h *AtomicWriteHandle) Rollback() error
Rollback reverts the write using the recorded backup.
type BaseRegistry ¶ added in v1.4.0
type BaseRegistry[T any] struct { // contains filtered or unexported fields }
BaseRegistry provides a thread-safe generic registry implementation
func NewBaseRegistry ¶ added in v1.4.0
func NewBaseRegistry[T any]() *BaseRegistry[T]
NewBaseRegistry creates a new generic registry
func (*BaseRegistry[T]) Get ¶ added in v1.4.0
func (r *BaseRegistry[T]) Get(name string) (T, bool)
Get retrieves a component by name
func (*BaseRegistry[T]) List ¶ added in v1.4.0
func (r *BaseRegistry[T]) List() []T
List returns all components in registration order
func (*BaseRegistry[T]) Names ¶ added in v1.4.0
func (r *BaseRegistry[T]) Names() []string
Names returns all component names in registration order
func (*BaseRegistry[T]) Register ¶ added in v1.4.0
func (r *BaseRegistry[T]) Register(name string, component T)
Register adds a component to the registry
type Config ¶
type Config struct {
// Database
DatabaseURL string
// Auto-apply settings
AutoApplyEnabled bool
AutoApplyThreshold float64
// Staging
StagingTTL time.Duration
// Session limits
MaxStagesPerSession int
MaxAppliesPerSession int
// Safety Configuration
Safety SafetyConfig
// Debug
Debug bool
// LogWriter allows tests to redirect debug logging; defaults to stderr.
LogWriter io.Writer
}
Config holds the MCP server configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a config with sensible defaults
type Error ¶
type Error = ErrorObject
Legacy aliases retained temporarily while refactoring call sites. They will be removed once all handlers are migrated to the new naming.
type ErrorObject ¶ added in v1.5.0
type ErrorObject struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
ErrorObject represents a JSON-RPC 2.0 error payload.
type FileIntegrityCheck ¶ added in v1.2.0
type LogLevel ¶ added in v1.2.0
type LogLevel string
LogLevel represents the severity level of a log message
type LogMessage ¶ added in v1.2.0
type LogMessage struct {
Level LogLevel `json:"level"`
Data LogData `json:"data,omitempty"`
Logger string `json:"logger,omitempty"`
}
LogMessage represents a log message according to MCP specification
type MCPError ¶
type MCPError struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
MCPError represents a structured error for the MCP protocol
func NewMCPError ¶
NewMCPError creates a new MCP error with optional data
type MCPMetrics ¶ added in v1.5.0
type MCPMetrics struct {
InboundMessages int64 `json:"inbound_messages"`
OutboundMessages int64 `json:"outbound_messages"`
PendingRequests int `json:"pending_requests"`
}
MCPMetrics captures lightweight counters for observability.
type Meta ¶ added in v1.5.0
Meta represents the optional `_meta` envelope that can accompany any request, notification, or response in the MCP transport. The structure is intentionally open-ended to support spec-defined fields like `progressToken` while allowing experimental metadata.
func (Meta) ProgressToken ¶ added in v1.5.0
ProgressToken returns the `_meta.progressToken` value if present.
func (Meta) WithProgressToken ¶ added in v1.5.0
WithProgressToken returns a copy of the metadata map with the provided progress token value applied. A zero-length token removes the field.
type Notification ¶
type Notification = NotificationMessage
Legacy aliases retained temporarily while refactoring call sites. They will be removed once all handlers are migrated to the new naming.
type NotificationHandler ¶ added in v1.5.0
type NotificationHandler func(ctx context.Context, msg NotificationMessage) error
NotificationHandler processes a JSON-RPC notification.
type NotificationMessage ¶ added in v1.5.0
type NotificationMessage struct {
JSONRPC string `json:"jsonrpc"`
Meta Meta `json:"_meta,omitempty"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
NotificationMessage represents a JSON-RPC 2.0 notification with no ID.
func NewNotificationMessage ¶ added in v1.5.0
func NewNotificationMessage(method string, params any) (NotificationMessage, error)
NewNotificationMessage constructs a notification envelope for the method.
type PromptContent ¶ added in v1.2.0
PromptContent represents the content of a prompt response
type PromptMessage ¶ added in v1.2.0
type PromptMessage struct {
Role string `json:"role"`
Content []PromptContent `json:"content"`
}
PromptMessage represents a prompt message
type PromptRegistry ¶ added in v1.4.0
type PromptRegistry struct {
*BaseRegistry[types.Prompt]
}
PromptRegistry manages prompt registration
func NewPromptRegistry ¶ added in v1.4.0
func NewPromptRegistry() *PromptRegistry
NewPromptRegistry creates a new prompt registry
type Registry ¶ added in v1.4.0
type Registry[T any] interface { Register(name string, component T) Get(name string) (T, bool) List() []T Names() []string }
Registry is a generic registry for MCP components
type Request ¶
type Request = RequestMessage
Legacy aliases retained temporarily while refactoring call sites. They will be removed once all handlers are migrated to the new naming.
type RequestHandler ¶ added in v1.5.0
type RequestHandler func(ctx context.Context, msg RequestMessage) ResponseMessage
RequestHandler processes a JSON-RPC request message and returns a response.
type RequestMessage ¶ added in v1.5.0
type RequestMessage struct {
JSONRPC string `json:"jsonrpc"`
Meta Meta `json:"_meta,omitempty"`
ID any `json:"id"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
RequestMessage represents a JSON-RPC 2.0 request that expects a response.
func NewRequestMessage ¶ added in v1.5.0
func NewRequestMessage(id any, method string, params any) (RequestMessage, error)
NewRequestMessage constructs a request envelope for the supplied method.
type ResourceContent ¶ added in v1.2.0
type ResourceContent struct {
URI string `json:"uri"`
MimeType string `json:"mimeType"`
Text string `json:"text,omitempty"`
Blob []byte `json:"blob,omitempty"`
}
ResourceContent represents the content of a resource
type ResourceRegistry ¶ added in v1.4.0
type ResourceRegistry struct {
*BaseRegistry[types.Resource]
}
ResourceRegistry manages resource registration
func NewResourceRegistry ¶ added in v1.4.0
func NewResourceRegistry() *ResourceRegistry
NewResourceRegistry creates a new resource registry
type ResourceTemplateRegistry ¶ added in v1.5.0
type ResourceTemplateRegistry struct {
*BaseRegistry[types.ResourceTemplateDefinition]
}
ResourceTemplateRegistry manages resource template registration
func NewResourceTemplateRegistry ¶ added in v1.5.0
func NewResourceTemplateRegistry() *ResourceTemplateRegistry
NewResourceTemplateRegistry creates a new resource template registry
type Response ¶
type Response = ResponseMessage
Legacy aliases retained temporarily while refactoring call sites. They will be removed once all handlers are migrated to the new naming.
type ResponseMessage ¶ added in v1.5.0
type ResponseMessage struct {
JSONRPC string `json:"jsonrpc"`
Meta Meta `json:"_meta,omitempty"`
ID any `json:"id"`
Result any `json:"result,omitempty"`
Error *ErrorObject `json:"error,omitempty"`
}
ResponseMessage represents a JSON-RPC 2.0 response to a request.
func ErrorResponse ¶
func ErrorResponse(id any, code int, message string, data ...any) ResponseMessage
ErrorResponse builds a response containing the supplied error object.
func SuccessResponse ¶
func SuccessResponse(id, result any) ResponseMessage
SuccessResponse builds a success response with the provided result payload.
type Router ¶ added in v1.5.0
type Router struct {
// contains filtered or unexported fields
}
Router maintains a registry of MCP request and notification handlers and provides centralized dispatch with JSON-RPC compliance checks.
func NewRouter ¶ added in v1.5.0
func NewRouter() *Router
NewRouter creates an empty router instance.
func (*Router) DispatchNotification ¶ added in v1.5.0
func (r *Router) DispatchNotification(ctx context.Context, msg NotificationMessage) error
DispatchNotification routes a notification message. If validation fails or the method is unknown the handler returns an error for logging.
func (*Router) DispatchRequest ¶ added in v1.5.0
func (r *Router) DispatchRequest(ctx context.Context, msg RequestMessage) ResponseMessage
DispatchRequest routes a request message to the appropriate handler. It returns a JSON-RPC error response if validation fails or the method is unknown.
func (*Router) RegisterNotification ¶ added in v1.5.0
func (r *Router) RegisterNotification(method string, handler NotificationHandler)
RegisterNotification associates a notification handler with a method name.
func (*Router) RegisterRequest ¶ added in v1.5.0
func (r *Router) RegisterRequest(method string, handler RequestHandler)
RegisterRequest associates a handler with a JSON-RPC method name. Existing registrations are replaced.
type SafetyConfig ¶ added in v1.2.0
type SafetyConfig struct {
// File operation limits
MaxFiles int `json:"max_files"` // Max files per operation
MaxFileSize int64 `json:"max_file_size"` // Max size per file (bytes)
MaxTotalSize int64 `json:"max_total_size"` // Max total operation size (bytes)
// Confidence validation
ConfidenceMode string `json:"confidence_mode"` // "global", "per_file", "both"
PerFileThreshold float64 `json:"per_file_threshold"` // Individual file threshold
GlobalThreshold float64 `json:"global_threshold"` // Overall operation threshold
// Hash validation
ValidateFileHashes bool `json:"validate_file_hashes"` // Check files weren't modified externally
// Atomic writes (always enabled for safety)
UseFsync bool `json:"use_fsync"` // Use fsync for durability
// Backup & rollback
CreateBackups bool `json:"create_backups"` // Create .bak files before writes
BackupSuffix string `json:"backup_suffix"` // Backup file suffix
TransactionLog bool `json:"transaction_log"` // Enable transaction logging
// Concurrency safety
FileLocking bool `json:"file_locking"` // Use file locking
LockTimeout time.Duration `json:"lock_timeout"` // Lock acquisition timeout
}
SafetyConfig holds safety-related configuration
type SafetyFile ¶ added in v1.2.0
type SafetyManager ¶ added in v1.2.0
type SafetyManager struct {
// contains filtered or unexported fields
}
SafetyManager handles all safety-related operations
func NewSafetyManager ¶ added in v1.2.0
func NewSafetyManager(config SafetyConfig) *SafetyManager
NewSafetyManager creates a new safety manager with the given config
func (*SafetyManager) AtomicWrite ¶ added in v1.2.0
func (sm *SafetyManager) AtomicWrite(path, content string) (*AtomicWriteHandle, error)
AtomicWrite performs an atomic write operation and, when transaction logging is enabled, returns a handle that can later be used to commit or roll back the persisted change. Atomic writes are always enabled for safety.
func (*SafetyManager) LockFile ¶ added in v1.2.0
func (sm *SafetyManager) LockFile(path string) (*FileLock, error)
LockFile acquires an exclusive lock on a file
func (*SafetyManager) ReleaseLock ¶ added in v1.2.0
func (sm *SafetyManager) ReleaseLock(path string) error
ReleaseLock releases a file lock
func (*SafetyManager) ValidateFileIntegrity ¶ added in v1.2.0
func (sm *SafetyManager) ValidateFileIntegrity(files []FileIntegrityCheck) error
ValidateFileIntegrity checks if files haven't been modified externally
func (*SafetyManager) ValidateOperation ¶ added in v1.2.0
func (sm *SafetyManager) ValidateOperation(op *SafetyOperation) error
ValidateOperation checks if an operation meets safety requirements
type SafetyOperation ¶ added in v1.2.0
type SafetyOperation struct {
Files []SafetyFile `json:"files"`
GlobalConfidence float64 `json:"global_confidence"`
}
type ServerInterface ¶ added in v1.4.0
type ServerInterface = types.ServerInterface
ServerInterface is now an alias to types.ServerInterface
type SessionState ¶ added in v1.5.0
type SessionState struct {
// contains filtered or unexported fields
}
SessionState captures negotiated protocol details and client preferences for the active MCP connection.
func NewSessionState ¶ added in v1.5.0
func NewSessionState() *SessionState
NewSessionState returns a session state with sensible defaults.
func (*SessionState) AppendElicitationRecord ¶ added in v1.5.0
func (s *SessionState) AppendElicitationRecord(params map[string]any, result map[string]any)
AppendElicitationRecord stores an elicitation exchange.
func (*SessionState) AppendSamplingRecord ¶ added in v1.5.0
func (s *SessionState) AppendSamplingRecord(params map[string]any, result map[string]any)
AppendSamplingRecord stores a sampling exchange for later inspection.
func (*SessionState) ClientCapabilities ¶ added in v1.5.0
func (s *SessionState) ClientCapabilities() map[string]any
ClientCapabilities returns a shallow copy of the negotiated capabilities.
func (*SessionState) ClientRoots ¶ added in v1.5.0
func (s *SessionState) ClientRoots() []string
ClientRoots returns the negotiated root directories from the client, if any.
func (*SessionState) ElicitationHistory ¶ added in v1.5.0
func (s *SessionState) ElicitationHistory() []types.ElicitationRecord
ElicitationHistory returns recorded elicitation exchanges.
func (*SessionState) Initialized ¶ added in v1.5.0
func (s *SessionState) Initialized() bool
Initialized reports whether the handshake has completed.
func (*SessionState) LoggingLevel ¶ added in v1.5.0
func (s *SessionState) LoggingLevel() LogLevel
LoggingLevel returns the currently configured minimum logging level.
func (*SessionState) MarkInitialized ¶ added in v1.5.0
func (s *SessionState) MarkInitialized(protocolVersion string, capabilities map[string]any)
MarkInitialized records the negotiated protocol version and client capabilities.
func (*SessionState) ProtocolVersion ¶ added in v1.5.0
func (s *SessionState) ProtocolVersion() string
ProtocolVersion returns the negotiated protocol version.
func (*SessionState) SamplingHistory ¶ added in v1.5.0
func (s *SessionState) SamplingHistory() []types.SamplingRecord
SamplingHistory retrieves a copy of recorded sampling exchanges.
func (*SessionState) SetClientRoots ¶ added in v1.5.0
func (s *SessionState) SetClientRoots(roots []string)
SetClientRoots records the roots returned by the client.
func (*SessionState) SetLoggingLevel ¶ added in v1.5.0
func (s *SessionState) SetLoggingLevel(level LogLevel)
SetLoggingLevel stores the requested minimum logging level.
type StagingManager ¶
type StagingManager struct {
// contains filtered or unexported fields
}
StagingManager handles staging and applying transformations
func NewStagingManager ¶
func NewStagingManager(db *gorm.DB, config Config, safety *SafetyManager) *StagingManager
NewStagingManager creates a new staging manager
func (*StagingManager) ApplyStage ¶
func (sm *StagingManager) ApplyStage(ctx context.Context, stageID string, autoApplied bool) (*models.Apply, error)
ApplyStage applies a staged transformation while honoring cancellation.
func (*StagingManager) CleanupExpiredStages ¶
func (sm *StagingManager) CleanupExpiredStages() error
CleanupExpiredStages marks expired stages
func (*StagingManager) CreateStage ¶
CreateStage creates a new staged transformation while honoring cancellation.
func (*StagingManager) DeleteAppliedStages ¶ added in v1.4.0
func (sm *StagingManager) DeleteAppliedStages(sessionID string) error
DeleteAppliedStages removes applied stages from database
func (*StagingManager) DeleteStage ¶ added in v1.4.0
func (sm *StagingManager) DeleteStage(stageID string) error
DeleteStage removes a specific stage by ID
func (*StagingManager) GetStage ¶
func (sm *StagingManager) GetStage(id string) (*models.Stage, error)
GetStage retrieves a stage by ID
func (*StagingManager) IsEnabled ¶ added in v1.5.0
func (sm *StagingManager) IsEnabled() bool
IsEnabled reports whether staging support is active. The manager is enabled whenever it has a backing database connection.
func (*StagingManager) ListPendingStages ¶
func (sm *StagingManager) ListPendingStages(sessionID string) ([]models.Stage, error)
ListPendingStages lists all pending stages for a session
type StdioServer ¶
type StdioServer struct {
// contains filtered or unexported fields
}
StdioServer handles MCP communication over stdio
func NewStdioServer ¶
func NewStdioServer(config Config) (*StdioServer, error)
NewStdioServer creates a new MCP server that communicates over stdio
func (*StdioServer) ConfirmApply ¶ added in v1.5.0
func (s *StdioServer) ConfirmApply(ctx context.Context, summary string) error
ConfirmApply requests client confirmation before applying staged changes.
func (*StdioServer) FinalizeTransform ¶ added in v1.5.0
func (s *StdioServer) FinalizeTransform(ctx context.Context, req types.TransformRequest) (map[string]any, error)
func (*StdioServer) GetFileProcessor ¶ added in v1.4.0
func (s *StdioServer) GetFileProcessor() *core.FileProcessor
GetFileProcessor returns the file processor
func (*StdioServer) GetProviders ¶ added in v1.4.0
func (s *StdioServer) GetProviders() *providers.Registry
GetProviders returns the provider registry
func (*StdioServer) GetSafety ¶ added in v1.4.0
func (s *StdioServer) GetSafety() any
GetSafety returns the safety manager
func (*StdioServer) GetSessionID ¶ added in v1.5.0
func (s *StdioServer) GetSessionID() string
GetSessionID returns the current persistence session identifier if available.
func (*StdioServer) GetStaging ¶ added in v1.4.0
func (s *StdioServer) GetStaging() any
GetStaging returns the staging manager
func (*StdioServer) LogDebug ¶ added in v1.2.0
func (s *StdioServer) LogDebug(message string, data ...LogData)
LogDebug sends a debug level log notification
func (*StdioServer) LogError ¶ added in v1.2.0
func (s *StdioServer) LogError(message string, data ...LogData)
LogError sends an error level log notification
func (*StdioServer) LogInfo ¶ added in v1.2.0
func (s *StdioServer) LogInfo(message string, data ...LogData)
LogInfo sends an info level log notification
func (*StdioServer) LogWarning ¶ added in v1.2.0
func (s *StdioServer) LogWarning(message string, data ...LogData)
LogWarning sends a warning level log notification
func (*StdioServer) Metrics ¶ added in v1.5.0
func (s *StdioServer) Metrics() MCPMetrics
Metrics exposes lightweight counters useful for debugging and observability.
func (*StdioServer) RegisterResource ¶ added in v1.5.0
func (s *StdioServer) RegisterResource(resource types.Resource)
RegisterResource adds or overrides a resource in the server registry.
func (*StdioServer) RegisterTool ¶
func (s *StdioServer) RegisterTool(name string, handler types.ToolHandler)
RegisterTool adds or overrides a tool handler in the modular registry. Primarily used in tests to stub tool behavior.
func (*StdioServer) ReportProgress ¶ added in v1.5.0
func (s *StdioServer) ReportProgress(ctx context.Context, progress, total float64, message string)
ReportProgress emits a progress notification if the context carries a token.
func (*StdioServer) RequestElicitation ¶ added in v1.5.0
func (s *StdioServer) RequestElicitation(ctx context.Context, params map[string]any) (map[string]any, error)
RequestElicitation requests an elicitation flow and records the interaction.
func (*StdioServer) RequestRoots ¶ added in v1.5.0
func (s *StdioServer) RequestRoots(ctx context.Context, params any, meta Meta) (ResponseMessage, error)
RequestRoots negotiates shared roots/list with the client.
func (*StdioServer) RequestSampling ¶ added in v1.5.0
func (s *StdioServer) RequestSampling(ctx context.Context, params map[string]any) (map[string]any, error)
RequestSampling requests a sampling message from the client and records it.
func (*StdioServer) RequestSamplingMessage ¶ added in v1.5.0
func (s *StdioServer) RequestSamplingMessage(ctx context.Context, params any, meta Meta) (ResponseMessage, error)
RequestSamplingMessage asks the client to generate a sampling message per MCP spec.
func (*StdioServer) ResourceDefinitions ¶ added in v1.5.0
func (s *StdioServer) ResourceDefinitions() []types.ResourceDefinition
func (*StdioServer) Start ¶
func (s *StdioServer) Start() error
Start begins processing JSON-RPC requests from stdin
type ToolRegistry ¶ added in v1.4.0
type ToolRegistry struct {
*BaseRegistry[types.Tool]
// contains filtered or unexported fields
}
ToolRegistry manages tool registration and execution
func NewToolRegistry ¶ added in v1.4.0
func NewToolRegistry(server ServerInterface) *ToolRegistry
NewToolRegistry creates a new tool registry
func (*ToolRegistry) Execute ¶ added in v1.4.0
func (tr *ToolRegistry) Execute(ctx context.Context, name string, params json.RawMessage) (any, error)
Execute runs a tool by name with the given parameters
func (*ToolRegistry) GetDefinitions ¶ added in v1.4.0
func (tr *ToolRegistry) GetDefinitions() []types.ToolDefinition
GetDefinitions returns tool definitions for MCP protocol
type Transaction ¶ added in v1.2.0
type Transaction struct {
ID string `json:"id"`
TargetPath string `json:"target_path"`
TmpPath string `json:"tmp_path"`
BackupPath string `json:"backup_path"`
Status string `json:"status"` // "pending", "completed", "failed", "rolled_back"
Error string `json:"error,omitempty"`
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
}
Transaction represents a file operation transaction
type TransactionLog ¶ added in v1.2.0
type TransactionLog struct {
// contains filtered or unexported fields
}
TransactionLog manages transaction logging for rollback capability
func NewTransactionLog ¶ added in v1.2.0
func NewTransactionLog() *TransactionLog
NewTransactionLog creates a new transaction log
func (*TransactionLog) BeginTransaction ¶ added in v1.2.0
func (tl *TransactionLog) BeginTransaction(targetPath, tmpPath, backupPath string) string
BeginTransaction starts a new transaction
func (*TransactionLog) CompleteTransaction ¶ added in v1.2.0
func (tl *TransactionLog) CompleteTransaction(txID string)
CompleteTransaction marks a transaction as completed
func (*TransactionLog) FailTransaction ¶ added in v1.2.0
func (tl *TransactionLog) FailTransaction(txID string, reason error) error
FailTransaction marks a transaction as failed and triggers rollback
func (*TransactionLog) GetPendingTransactions ¶ added in v1.2.0
func (tl *TransactionLog) GetPendingTransactions() []*Transaction
GetPendingTransactions returns all pending transactions
func (*TransactionLog) GetSummary ¶ added in v1.2.0
func (tl *TransactionLog) GetSummary() TransactionSummary
GetSummary returns a summary of the transaction log
func (*TransactionLog) RollbackAll ¶ added in v1.2.0
func (tl *TransactionLog) RollbackAll() error
RollbackAll rolls back all pending transactions
func (*TransactionLog) RollbackTransaction ¶ added in v1.2.0
func (tl *TransactionLog) RollbackTransaction(txID string) error
RollbackTransaction performs rollback for a specific transaction
type TransactionSummary ¶ added in v1.2.0
type TransactionSummary struct {
TotalTransactions int `json:"total_transactions"`
PendingTransactions int `json:"pending_transactions"`
CompletedTransactions int `json:"completed_transactions"`
FailedTransactions int `json:"failed_transactions"`
RolledBackTransactions int `json:"rolled_back_transactions"`
}
TransactionSummary provides a summary of transaction log state
Source Files
¶
- async_staging.go
- config.go
- errors.go
- file_safety_adapter.go
- handlers.go
- logging.go
- pagination.go
- progress.go
- prompts.go
- protocol.go
- query_wrapper.go
- registry.go
- resource_templates.go
- resources.go
- router.go
- safety.go
- safety_process_unix.go
- server.go
- server_interface.go
- session_state.go
- staging.go
- test_db_helpers.go
- transaction_log.go
- transform_finalize.go
- utils.go