Documentation
¶
Overview ¶
Package processor provides execution logic for MCP request/response processors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrProcessorDisabled = errors.New("processor is disabled")
ErrProcessorDisabled indicates processor creation was requested for a disabled processor config.
Functions ¶
Types ¶
type CLIProcessor ¶ added in v0.0.3
type CLIProcessor struct {
// WorkingDir is the directory where processor commands are executed.
// Defaults to user's home directory.
WorkingDir string
// contains filtered or unexported fields
}
CLIProcessor performs a CLI execution.
func NewCLIProcessor ¶ added in v0.0.3
func NewCLIProcessor(c *config.ProcessorConfig) (*CLIProcessor, error)
NewCLIProcessor creates a new NewCLIProcessor.
func (*CLIProcessor) GetConfig ¶ added in v0.0.3
func (e *CLIProcessor) GetConfig() *config.ProcessorConfig
GetConfig returns the attached ProcessorConfig.
func (*CLIProcessor) Process ¶ added in v0.0.3
func (e *CLIProcessor) Process(input *DataContext) (*DataContext, error)
Process runs a processor with the given input and returns the output. It handles CLI processor execution with timeout, and error handling.
Note: the Processors responsibility is to execute a specific action, its NOT to serialize back the result into the correct data format - this is done in the handler.
type DataContext ¶ added in v0.0.3
type DataContext struct {
Version string `json:"version"` // "1.0" - for evolution
// Parts - only populated based on processor config
Event *common.MCPEvent `json:"event,omitempty"` // Contains event metadata
Payload *PayloadPart `json:"payload,omitempty"` // Payload of the request and result
Routing *RoutingPart `json:"routing,omitempty"`
Auth *common.AuthContext `json:"auth,omitempty"` // Auth identity and principal context
}
DataContext is passed to processors as JSON. Holds all relevant information of a CallContext for processors to access and modify.
type PayloadPart ¶ added in v0.0.3
type PayloadPart struct {
Request *mcp.CallToolRequest `json:"request,omitempty"` // The processed mcp.CallToolRequest
OriginalRequest *mcp.CallToolRequest `json:"original_request,omitempty"` // The original mcp.CallToolRequest coming from upstream client
Result *mcp.CallToolResult `json:"result,omitempty"` // The processed mcp.CallToolResult
OriginalResult *mcp.CallToolResult `json:"original_result,omitempty"` // The original mcp.CallToolResult coming from downstream MCP
}
PayloadPart holds payload information in ProcessorContext.
type ProcessorInterface ¶ added in v0.0.3
type ProcessorInterface interface {
// Process takes an input and performs the configured action
// - e.g. calling a CLI command, executing a webhook, etc.
//
// error indicates a failure to process the input
// - it's not to be confused with an error status of
// the payload (e.g. by evaluation processors).
Process(input *DataContext) (*DataContext, error)
// GetConfig returns the processors config
GetConfig() *config.ProcessorConfig
}
ProcessorInterface interfaces all Processor implementations.
func NewProcessor ¶ added in v0.0.3
func NewProcessor(processorConfig *config.ProcessorConfig) (ProcessorInterface, error)
NewProcessor creates a new processor using the provided ProcessorConfig
Currently, it only supports "cli" processors and returns an error if Type != "cli".
type RoutingPart ¶ added in v0.0.3
type RoutingPart struct {
ServerName string `json:"server_name"`
ToolName string `json:"tool_name"`
OriginalServerName string `json:"original_server_name"`
OriginalToolname string `json:"original_tool_name"`
}
RoutingPart holds routing information in ProcessorContext.