processor

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package processor provides execution logic for MCP request/response processors.

Index

Constants

View Source
const CurrentDataContextVersion = "1.0"

CurrentDataContextVersion is the data contract version sent to processors. Follows major.minor semantics: a major bump is breaking, a minor bump is additive and backward-compatible (processors that ignore unknown fields remain functional).

Variables

View Source
var ErrProcessorDisabled = errors.New("processor is disabled")

ErrProcessorDisabled indicates processor creation was requested for a disabled processor config.

Functions

func RunScaffoldInteractive

func RunScaffoldInteractive(in io.Reader, out io.Writer) error

RunScaffoldInteractive creates a processor scaffold via interactive prompts.

Types

type AnnotationPart added in v0.4.3

type AnnotationPart struct {
	Reports []Report `json:"reports,omitempty"`
}

AnnotationPart lets processors report findings about an event without modifying the MCP call.

type BuiltinProcessor added in v0.4.3

type BuiltinProcessor struct {
	// contains filtered or unexported fields
}

BuiltinProcessor runs a processor implementation compiled into Centian.

func NewBuiltinProcessor added in v0.4.3

func NewBuiltinProcessor(c *config.ProcessorConfig) (*BuiltinProcessor, error)

NewBuiltinProcessor creates a built-in processor from config.

func (*BuiltinProcessor) GetConfig added in v0.4.3

func (b *BuiltinProcessor) GetConfig() *config.ProcessorConfig

GetConfig returns the attached ProcessorConfig.

func (*BuiltinProcessor) Process added in v0.4.3

func (b *BuiltinProcessor) Process(input *DataContext) (*DataContext, error)

Process runs the configured built-in processor against the input context.

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.MetaContext `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
	Annotations *AnnotationPart     `json:"annotations,omitempty"`
}

DataContext is passed to processors as JSON. Holds all relevant information of a CallContext for processors to access and modify.

type Finding added in v0.4.3

Finding identifies a specific processor finding.

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.

type Report added in v0.4.3

type Report = common.EventAnnotation

Report describes a processor observation or policy action.

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.

type WebhookProcessor added in v0.0.6

type WebhookProcessor struct {
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

WebhookProcessor performs synchronous HTTP POST execution against a remote processor.

func NewWebhookProcessor added in v0.0.6

func NewWebhookProcessor(c *config.ProcessorConfig) (*WebhookProcessor, error)

NewWebhookProcessor creates a new WebhookProcessor.

func (*WebhookProcessor) GetConfig added in v0.0.6

func (w *WebhookProcessor) GetConfig() *config.ProcessorConfig

GetConfig returns the attached ProcessorConfig.

func (*WebhookProcessor) Process added in v0.0.6

func (w *WebhookProcessor) Process(input *DataContext) (*DataContext, error)

Process sends the reduced processor input DTO to the configured webhook and decodes the synchronous JSON response into a DataContext.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL