Documentation
¶
Overview ¶
framework/color_helper.go
Index ¶
- func PrintError(err error)
- func PrintMetrics(metrics map[string]interface{})
- func PrintServerConfig(config map[string]string)
- func PrintShutdownMessage()
- func PrintStartupBanner(name, version, description string)
- func PrintStartupMessage(transport, address string)
- func PrintToolsList(tools []string)
- type BackendConfig
- type Config
- type HTTPConfig
- type LoggingConfig
- type ObservabilityConfig
- type Option
- func WithAuth(authType string, config interface{}) Option
- func WithAuthProvider(name string, provider auth.AuthProvider) Option
- func WithAuthResource(providerName string, resource auth.ResourceConfig) Option
- func WithAutoColors() Option
- func WithBackend(b backend.ServerBackend) Option
- func WithBackendType(backendType string) Option
- func WithCache(cacheType string, ttl int) Option
- func WithCacheConfig(config *cache.Config) Option
- func WithCacheDisabled() Option
- func WithCacheSize(maxSize int) Option
- func WithColors(enable bool) Option
- func WithConfig(config *Config) Option
- func WithConfigFile(path string) Option
- func WithFacebook(clientID, clientSecret, redirectURL string, scopes []string) Option
- func WithGitHub(clientID, clientSecret, redirectURL string, scopes []string) Option
- func WithGoogle(clientID, clientSecret, redirectURL string, scopes []string) Option
- func WithHTTPAddress(addr string) Option
- func WithLogLevel(level string) Option
- func WithMaxConcurrent(max int) Option
- func WithMaxEvents(max int64) Option
- func WithMetricsAddress(addr string) Option
- func WithMicrosoft(clientID, clientSecret, redirectURL string, scopes []string) Option
- func WithOAuth(providerName, clientID, clientSecret, redirectURL string, scopes []string) Option
- func WithOAuth2Token(providerName string, token *auth.OAuth2Token) Option
- func WithObservability(enabled bool) Option
- func WithSlack(clientID, clientSecret, redirectURL string, scopes []string) Option
- func WithStreaming(enabled bool) Option
- func WithStreamingBufferSize(size int) Option
- func WithStreamingTimeout(timeout time.Duration) Option
- func WithToolCacheTTL(toolName string, ttl time.Duration) Option
- func WithTransport(transport string) Option
- type Server
- func (s *Server) GetAuthManager() *auth.Manager
- func (s *Server) GetBackend() backend.ServerBackend
- func (s *Server) GetCache() cache.Cache
- func (s *Server) GetCacheConfig() *cache.Config
- func (s *Server) GetExecutor() *engine.Executor
- func (s *Server) GetKeyGenerator() *cache.KeyGenerator
- func (s *Server) GetLogger() *slog.Logger
- func (s *Server) Initialize(ctx context.Context) error
- func (s *Server) RegisterBackend(b backend.ServerBackend)
- func (s *Server) RegisterFunction(name string, handler backend.StreamingHandler)
- func (s *Server) Run(ctx context.Context) error
- type StreamingConfig
- type TransportConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintError ¶ added in v0.3.0
func PrintError(err error)
PrintError prints a colored error message
func PrintMetrics ¶ added in v0.3.0
func PrintMetrics(metrics map[string]interface{})
PrintMetrics prints metrics in a colored format
func PrintServerConfig ¶ added in v0.3.0
PrintServerConfig prints server configuration in a colorful table
func PrintShutdownMessage ¶ added in v0.3.0
func PrintShutdownMessage()
PrintShutdownMessage prints a shutdown message
func PrintStartupBanner ¶ added in v0.3.0
func PrintStartupBanner(name, version, description string)
PrintStartupBanner prints a colorful startup banner
func PrintStartupMessage ¶ added in v0.3.0
func PrintStartupMessage(transport, address string)
PrintStartupMessage prints a formatted startup message
func PrintToolsList ¶ added in v0.3.0
func PrintToolsList(tools []string)
PrintToolsList prints available tools in a colored format
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 ¶
LoadConfig loads configuration from a YAML file
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 WithAuthProvider ¶ added in v0.3.0
func WithAuthProvider(name string, provider auth.AuthProvider) Option
WithAuthProvider directly sets an auth provider
func WithAuthResource ¶ added in v0.3.0
func WithAuthResource(providerName string, resource auth.ResourceConfig) Option
WithAuthResource registers a resource with an auth provider
func WithAutoColors ¶ added in v0.3.0
func WithAutoColors() Option
WithAutoColors returns a function option to auto-detect color support
func WithBackend ¶
func WithBackend(b backend.ServerBackend) Option
WithBackend sets a specific backend instance
func WithBackendType ¶
WithBackendType sets the backend type
func WithCache ¶ added in v0.4.0
WithCache configures response caching
Example:
framework.NewServer(
framework.WithCache("short", 60), // 60 seconds
)
func WithCacheConfig ¶ added in v0.4.0
WithCacheConfig sets the complete cache configuration
func WithCacheDisabled ¶ added in v0.4.0
func WithCacheDisabled() Option
WithCacheDisabled explicitly disables caching
func WithCacheSize ¶ added in v0.4.0
WithCacheSize sets the maximum cache size (for memory cache)
func WithColors ¶ added in v0.3.0
WithColors returns a function option to enable colored output
func WithConfigFile ¶
WithConfigFile sets the config file path
func WithFacebook ¶ added in v0.3.0
WithFacebook is a convenience function for Facebook OAuth2
func WithGitHub ¶ added in v0.3.0
WithGitHub is a convenience function for GitHub OAuth2
func WithGoogle ¶ added in v0.3.0
WithGoogle is a convenience function for Google OAuth2
func WithHTTPAddress ¶
WithHTTPAddress sets the HTTP server address
func WithMaxConcurrent ¶ added in v0.2.0
WithMaxConcurrent sets maximum concurrent executions
func WithMaxEvents ¶ added in v0.2.0
WithMaxEvents sets maximum events per execution
func WithMetricsAddress ¶
WithMetricsAddress sets the metrics server address
func WithMicrosoft ¶ added in v0.3.0
WithMicrosoft is a convenience function for Microsoft OAuth2
func WithOAuth2Token ¶ added in v0.3.0
func WithOAuth2Token(providerName string, token *auth.OAuth2Token) Option
WithOAuth2Token sets a pre-configured OAuth2 token
func WithObservability ¶
WithObservability enables/disables observability
func WithStreaming ¶ added in v0.2.0
WithStreaming enables/disables streaming
func WithStreamingBufferSize ¶ added in v0.2.0
WithStreamingBufferSize sets the event buffer size
func WithStreamingTimeout ¶ added in v0.2.0
WithStreamingTimeout sets the execution timeout
func WithToolCacheTTL ¶ added in v0.4.0
WithToolCacheTTL sets per-tool TTL override
Example:
framework.NewServer(
framework.WithCache("short", 60),
framework.WithToolCacheTTL("search", 30*time.Second),
)
func WithTransport ¶
WithTransport sets the transport type
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the main MCP server
func (*Server) GetAuthManager ¶ added in v0.3.0
GetAuthManager returns the auth manager
func (*Server) GetBackend ¶ added in v0.2.0
func (s *Server) GetBackend() backend.ServerBackend
GetBackend returns the current backend
func (*Server) GetCacheConfig ¶ added in v0.4.0
GetCacheConfig returns the cache configuration
func (*Server) GetExecutor ¶ added in v0.2.0
GetExecutor returns the streaming executor
func (*Server) GetKeyGenerator ¶ added in v0.4.0
func (s *Server) GetKeyGenerator() *cache.KeyGenerator
GetKeyGenerator returns the key generator
func (*Server) Initialize ¶ added in v0.2.0
Initialize initializes the server
func (*Server) RegisterBackend ¶ added in v0.2.0
func (s *Server) RegisterBackend(b backend.ServerBackend)
RegisterBackend registers a full backend
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
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