Help us shape the future of Go! Take the 2026 Go Developer Survey

processor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 16 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 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

}

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.

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