Documentation
¶
Index ¶
- Constants
- type AsyncStagingManager
- type Config
- type Error
- type HTTPServer
- type MCPError
- type Notification
- type Request
- type Response
- type StagingManager
- func (sm *StagingManager) ApplyStage(stageID string, autoApplied bool) (*models.Apply, error)
- func (sm *StagingManager) CleanupExpiredStages() error
- func (sm *StagingManager) CreateStage(stage *models.Stage) error
- func (sm *StagingManager) GetStage(id string) (*models.Stage, error)
- func (sm *StagingManager) ListPendingStages(sessionID string) ([]models.Stage, error)
- type StdioServer
- type ToolDefinition
- type ToolHandler
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 )
Error codes following JSON-RPC 2.0 standard and custom domain errors
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) *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
CreateStageAsync stages transformation without blocking
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
// Debug
Debug bool
}
Config holds the MCP server configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a config with sensible defaults
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
Error represents a JSON-RPC 2.0 error
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer handles MCP communication over HTTP
func NewHTTPServer ¶
func NewHTTPServer(config Config, host string, port int, apiKey, corsOrigin string) (*HTTPServer, error)
NewHTTPServer creates a new HTTP server that provides MCP functionality via REST API
func (*HTTPServer) Close ¶
func (s *HTTPServer) Close() error
Close closes the HTTP server and cleans up resources
type MCPError ¶
type MCPError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
MCPError represents a structured error for the MCP protocol
func NewMCPError ¶
NewMCPError creates a new MCP error with optional data
type Notification ¶
type Notification struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
}
Notification is a request without an ID (no response expected)
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
ID interface{} `json:"id"`
}
Request represents a JSON-RPC 2.0 request
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
Result interface{} `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
ID interface{} `json:"id"`
}
Response represents a JSON-RPC 2.0 response
func ErrorResponse ¶
ErrorResponse creates a JSON-RPC error response
func ErrorResponseWithData ¶
ErrorResponseWithData creates a JSON-RPC error response with additional data
func SuccessResponse ¶
func SuccessResponse(id interface{}, result interface{}) Response
Standard JSON-RPC error codes SuccessResponse creates a success response
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) *StagingManager
NewStagingManager creates a new staging manager
func (*StagingManager) ApplyStage ¶
ApplyStage applies a staged transformation
func (*StagingManager) CleanupExpiredStages ¶
func (sm *StagingManager) CleanupExpiredStages() error
CleanupExpiredStages marks expired stages
func (*StagingManager) CreateStage ¶
func (sm *StagingManager) CreateStage(stage *models.Stage) error
CreateStage creates a new staged transformation
func (*StagingManager) GetStage ¶
func (sm *StagingManager) GetStage(id string) (*models.Stage, error)
GetStage retrieves a stage by ID
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) RegisterTool ¶
func (s *StdioServer) RegisterTool(name string, handler ToolHandler)
RegisterTool adds a custom tool handler
func (*StdioServer) Start ¶
func (s *StdioServer) Start() error
Start begins processing JSON-RPC requests from stdin
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]interface{} `json:"inputSchema"`
}
ToolDefinition describes a tool for the client
func GetToolDefinitions ¶
func GetToolDefinitions() []ToolDefinition
GetToolDefinitions returns all available tool definitions
type ToolHandler ¶
type ToolHandler func(params json.RawMessage) (interface{}, error)
ToolHandler represents a function that handles a tool call