framework

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendConfig

type BackendConfig struct {
	Type   string                 `yaml:"type"`
	Config map[string]interface{} `yaml:"config"`
}

BackendConfig configures the backend

type Config

type Config struct {
	Backend       BackendConfig       `yaml:"backend"`
	Transport     TransportConfig     `yaml:"transport"`
	Observability ObservabilityConfig `yaml:"observability"`
	Logging       LoggingConfig       `yaml:"logging"`
	Streaming     StreamingConfig     `yaml:"streaming"` // NEW
}

Config represents the complete server configuration

func DefaultConfig added in v0.2.0

func DefaultConfig() *Config

DefaultConfig returns the default configuration

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads configuration from a YAML file

func (*Config) Validate added in v0.2.0

func (c *Config) Validate() error

Validate validates the configuration

type HTTPConfig

type HTTPConfig struct {
	Address        string        `yaml:"address"`
	ReadTimeout    time.Duration `yaml:"read_timeout"`
	WriteTimeout   time.Duration `yaml:"write_timeout"`
	MaxRequestSize int64         `yaml:"max_request_size"`
	AllowedOrigins []string      `yaml:"allowed_origins"`
}

HTTPConfig configures HTTP transport

type LoggingConfig

type LoggingConfig struct {
	Level     string `yaml:"level"`
	Format    string `yaml:"format"`
	AddSource bool   `yaml:"add_source"`
}

LoggingConfig configures logging

type ObservabilityConfig

type ObservabilityConfig struct {
	Enabled        bool   `yaml:"enabled"`
	MetricsAddress string `yaml:"metrics_address"`
}

ObservabilityConfig configures observability features

type Option

type Option func(*Server)

Option configures the server

func WithBackend

func WithBackend(b backend.ServerBackend) Option

WithBackend sets a specific backend instance

func WithBackendType

func WithBackendType(backendType string) Option

WithBackendType sets the backend type

func WithConfig

func WithConfig(config *Config) Option

WithConfig sets the complete configuration

func WithConfigFile

func WithConfigFile(path string) Option

WithConfigFile sets the config file path

func WithHTTPAddress

func WithHTTPAddress(addr string) Option

WithHTTPAddress sets the HTTP server address

func WithLogLevel

func WithLogLevel(level string) Option

WithLogLevel sets the log level

func WithMaxConcurrent added in v0.2.0

func WithMaxConcurrent(max int) Option

WithMaxConcurrent sets maximum concurrent executions (v2 semaphore)

func WithMaxEvents added in v0.2.0

func WithMaxEvents(max int64) Option

WithMaxEvents sets maximum events per execution

func WithMetricsAddress

func WithMetricsAddress(addr string) Option

WithMetricsAddress sets the metrics server address

func WithObservability

func WithObservability(enabled bool) Option

WithObservability enables/disables observability

func WithStreaming added in v0.2.0

func WithStreaming(enabled bool) Option

WithStreaming enables/disables streaming

func WithStreamingBufferSize added in v0.2.0

func WithStreamingBufferSize(size int) Option

WithStreamingBufferSize sets the event buffer size

func WithStreamingTimeout added in v0.2.0

func WithStreamingTimeout(timeout time.Duration) Option

WithStreamingTimeout sets the execution timeout

func WithTransport

func WithTransport(transport string) Option

WithTransport sets the transport type

type Server

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

Server is the main MCP server

func NewServer

func NewServer(opts ...Option) *Server

NewServer creates a new MCP server

func (*Server) GetBackend added in v0.2.0

func (s *Server) GetBackend() backend.ServerBackend

GetBackend returns the current backend

func (*Server) GetExecutor added in v0.2.0

func (s *Server) GetExecutor() *engine.Executor

GetExecutor returns the streaming executor

func (*Server) Initialize added in v0.2.0

func (s *Server) Initialize(ctx context.Context) error

Initialize initializes the server

func (*Server) RegisterBackend added in v0.2.0

func (s *Server) RegisterBackend(b backend.ServerBackend)

RegisterBackend registers a full backend (v0.2.0 style) This is the complete API for production use cases with multiple tools

func (*Server) RegisterFunction added in v0.2.0

func (s *Server) RegisterFunction(name string, handler backend.StreamingHandler)

RegisterFunction registers a single streaming function as a tool (v2 style) This is a simplified API for quick prototyping and simple use cases

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server

type StreamingConfig added in v0.2.0

type StreamingConfig struct {
	Enabled       bool          `yaml:"enabled"`
	BufferSize    int           `yaml:"buffer_size"`
	Timeout       time.Duration `yaml:"timeout"`
	MaxEvents     int64         `yaml:"max_events"`
	MaxConcurrent int           `yaml:"max_concurrent"` // NEW: v2 semaphore
}

StreamingConfig configures streaming execution (NEW - v2 feature)

type TransportConfig

type TransportConfig struct {
	Type  string     `yaml:"type"`
	HTTP  HTTPConfig `yaml:"http"`
	Stdio struct{}   `yaml:"stdio"`
}

TransportConfig configures the transport layer

Jump to

Keyboard shortcuts

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