Documentation
¶
Index ¶
- func Load(ctx context.Context, configs []config.MCPServerConfig, logger core.Logger) ([]core.Action, error)
- func LoadWithFactory(ctx context.Context, configs []config.MCPServerConfig, factory ClientFactory, ...) ([]core.Action, error)
- type Client
- type ClientFactory
- type DefaultFactory
- type Loader
- type MCPAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load(ctx context.Context, configs []config.MCPServerConfig, logger core.Logger) ([]core.Action, error)
Load is a convenience function for backward compatibility or bulk loading. Deprecated: Use NewLoader(cfg).WithLogger(logger).Load(ctx) instead for better error handling.
func LoadWithFactory ¶
func LoadWithFactory(ctx context.Context, configs []config.MCPServerConfig, factory ClientFactory, logger core.Logger) ([]core.Action, error)
LoadWithFactory allows injection of a custom ClientFactory for testing. Deprecated: Use NewLoader(cfg).WithFactory(f).Load(ctx) instead.
Types ¶
type Client ¶
Client defines the interface for an MCP client wrapper. This allows us to mock the client in tests.
type ClientFactory ¶
type ClientFactory interface {
CreateClient(ctx context.Context, cfg config.MCPServerConfig) (Client, error)
}
ClientFactory is an interface for creating MCP clients.
type DefaultFactory ¶
type DefaultFactory struct{}
DefaultFactory implements ClientFactory using the real Genkit MCP plugin.
func (*DefaultFactory) CreateClient ¶
func (f *DefaultFactory) CreateClient(ctx context.Context, cfg config.MCPServerConfig) (Client, error)
CreateClient creates a new GenkitMCPClient.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles the initialization of an MCP server.
func NewLoader ¶
func NewLoader(cfg config.MCPServerConfig) *Loader
NewLoader creates a new Loader for the given configuration.
func (*Loader) Load ¶
Load connects to the MCP server and returns the discovered actions. It implements the Driver Resilience (Health Check) pattern. If FailOnStartup is true, it returns connection errors. If FailOnStartup is false (default), it logs a warning and returns "Unhealthy" actions for expected tools defined in the config.
func (*Loader) WithFactory ¶
func (l *Loader) WithFactory(f ClientFactory) *Loader
WithFactory allows overriding the default ClientFactory (useful for testing).
type MCPAction ¶
type MCPAction struct {
// contains filtered or unexported fields
}
MCPAction wraps a Genkit AI Tool discovered from an MCP server.
func NewAction ¶
NewAction creates a new MCPAction. If tool is nil (e.g. startup failure), name must be provided.
func (*MCPAction) Metadata ¶
func (a *MCPAction) Metadata() core.ActionMetadata
Metadata returns the action metadata.