plugin

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MCPDisabled added in v1.1.34

func MCPDisabled(name string) bool

MCPDisabled returns whether the named MCP server is disabled.

func SetMCPDisabled added in v1.1.34

func SetMCPDisabled(name string, disabled bool)

SetMCPDisabled persists the enabled/disabled state for an MCP server.

Types

type CommandTool

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

CommandTool wraps an external command as a tool.Tool.

func NewCommandTool

func NewCommandTool(name, description, execute string, args []string) *CommandTool

NewCommandTool creates a tool that runs an external command.

func (*CommandTool) Description

func (c *CommandTool) Description() string

func (*CommandTool) Execute

func (c *CommandTool) Execute(ctx context.Context, input json.RawMessage) (tool.Result, error)

func (*CommandTool) Name

func (c *CommandTool) Name() string

func (*CommandTool) Parameters

func (c *CommandTool) Parameters() json.RawMessage

type LoadResult

type LoadResult struct {
	Name    string
	Success bool
	Tools   []string
	Error   error
}

LoadResult describes the outcome of loading a single plugin.

type MCPManager

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

func NewMCPManager

func NewMCPManager(servers []config.MCPServerConfig, registry *tool.Registry) *MCPManager

func (*MCPManager) ClearPendingOAuth added in v1.1.34

func (m *MCPManager) ClearPendingOAuth()

func (*MCPManager) Close

func (m *MCPManager) Close() error

func (*MCPManager) ConnectAll

func (m *MCPManager) ConnectAll(ctx context.Context) []string

func (*MCPManager) Disconnect added in v1.1.34

func (m *MCPManager) Disconnect(name string) bool

Disconnect closes the MCP server connection and unregisters its tools, but keeps the plugin in the list so it can be reconnected later. Runs asynchronously to avoid blocking the caller.

func (*MCPManager) GetPrompt

func (m *MCPManager) GetPrompt(ctx context.Context, server, name string, args map[string]interface{}) (*tool.MCPPromptResult, error)

func (*MCPManager) Install

func (m *MCPManager) Install(ctx context.Context, server config.MCPServerConfig) error

func (*MCPManager) PendingOAuth added in v1.1.34

func (m *MCPManager) PendingOAuth() *MCPOAuthRequiredError

func (*MCPManager) ReadResource

func (m *MCPManager) ReadResource(ctx context.Context, server, uri string) (*tool.MCPResourceResult, error)

func (*MCPManager) Reconnect added in v1.1.34

func (m *MCPManager) Reconnect(name string) bool

Reconnect reconnects a previously disconnected MCP server.

func (*MCPManager) Retry

func (m *MCPManager) Retry(name string) bool

func (*MCPManager) SetOnUpdate

func (m *MCPManager) SetOnUpdate(fn func([]MCPServerInfo))

func (*MCPManager) SetURLOpener added in v1.1.34

func (m *MCPManager) SetURLOpener(fn func(string) error)

func (*MCPManager) Snapshot

func (m *MCPManager) Snapshot() []MCPServerInfo

func (*MCPManager) SnapshotMCP

func (m *MCPManager) SnapshotMCP() []tool.MCPServerSnapshot

func (*MCPManager) StartBackground

func (m *MCPManager) StartBackground(ctx context.Context)

func (*MCPManager) Uninstall

func (m *MCPManager) Uninstall(name string) bool

type MCPOAuthRequiredError added in v1.1.34

type MCPOAuthRequiredError struct {
	ServerName string
	Handler    *mcp.OAuthHandler
}

MCPOAuthRequiredError signals that OAuth is needed for an MCP server.

func (*MCPOAuthRequiredError) Error added in v1.1.34

func (e *MCPOAuthRequiredError) Error() string

type MCPPlugin

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

MCPPlugin connects to an MCP server and registers its tools.

func NewMCPPlugin

func NewMCPPlugin(cfg config.MCPServerConfig) *MCPPlugin

NewMCPPlugin creates a plugin from an MCP server configuration.

func (*MCPPlugin) Adapter

func (m *MCPPlugin) Adapter() *mcp.Adapter

Adapter returns the MCP adapter (nil if not connected).

func (*MCPPlugin) Close

func (m *MCPPlugin) Close() error

func (*MCPPlugin) Connect

func (m *MCPPlugin) Connect(ctx context.Context) (*mcp.Adapter, error)

Connect initializes the MCP server, discovers tools, and returns an adapter.

func (*MCPPlugin) GetPrompt

func (m *MCPPlugin) GetPrompt(ctx context.Context, name string, args map[string]interface{}) (*mcp.GetPromptResult, error)

func (*MCPPlugin) Info

func (m *MCPPlugin) Info() MCPServerInfo

func (*MCPPlugin) Init

func (m *MCPPlugin) Init(cfg map[string]interface{}) error

func (*MCPPlugin) IsConnected

func (m *MCPPlugin) IsConnected() bool

IsConnected returns whether the MCP server has been successfully contacted.

func (*MCPPlugin) LastError

func (m *MCPPlugin) LastError() string

func (*MCPPlugin) Name

func (m *MCPPlugin) Name() string

func (*MCPPlugin) ReadResource

func (m *MCPPlugin) ReadResource(ctx context.Context, uri string) (*mcp.ReadResourceResult, error)

func (*MCPPlugin) RegisterTools

func (m *MCPPlugin) RegisterTools(ctx context.Context, registry *tool.Registry) error

RegisterTools discovers MCP tools and registers them into the registry.

func (*MCPPlugin) Status

func (m *MCPPlugin) Status() MCPStatus

func (*MCPPlugin) Tools

func (m *MCPPlugin) Tools() []tool.Tool

Tools returns the registered tool names (requires prior Connect).

type MCPServerInfo

type MCPServerInfo struct {
	Name          string
	Transport     string
	Source        string
	ToolNames     []string
	PromptNames   []string
	ResourceNames []string
	Status        MCPStatus
	Error         string
	Migrated      bool
	Disabled      bool
}

type MCPStatus

type MCPStatus string
const (
	MCPStatusPending   MCPStatus = "pending"
	MCPStatusConnected MCPStatus = "connected"
	MCPStatusFailed    MCPStatus = "failed"
)

type Manager

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

Manager handles loading, initializing, and tracking plugins.

func NewManager

func NewManager() *Manager

NewManager creates a new plugin manager.

func (*Manager) AddPlugin

func (m *Manager) AddPlugin(p Plugin)

AddPlugin adds a pre-initialized plugin to the manager.

func (*Manager) LoadAll

func (m *Manager) LoadAll(entries []config.PluginConfigEntry)

LoadAll loads plugins from config entries and the default plugin directory. Individual failures are recorded but do not block startup.

func (*Manager) Plugins

func (m *Manager) Plugins() []Plugin

Plugins returns all successfully loaded plugins.

func (*Manager) RegisterTools

func (m *Manager) RegisterTools(registry *tool.Registry) error

RegisterTools registers all plugin tools into the given registry.

func (*Manager) Results

func (m *Manager) Results() []LoadResult

Results returns the load results for all plugins (including failures).

type Plugin

type Plugin interface {
	// Name returns a unique identifier for this plugin.
	Name() string

	// Tools returns the list of tools this plugin provides.
	Tools() []tool.Tool

	// Init initializes the plugin with optional configuration.
	// Called once after loading, before tools are registered.
	Init(config map[string]interface{}) error
}

Plugin is the interface that external tool plugins must implement. Plugins provide one or more tools that get registered in the tool registry.

Jump to

Keyboard shortcuts

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