Documentation
¶
Index ¶
- Variables
- func CloseGlobalManager() error
- func GetAgentMCPServers(cfg *config.Config, agentName string) ([]string, error)
- func GetServerConfig(cfg *config.Config, serverName string) (*config.MCPServer, error)
- func InitializeGlobalManager(ctx context.Context, cfg *config.Config) error
- func IsConfigError(err error) bool
- func IsConnectionError(err error) bool
- func ShortError(err error) string
- func ValidateConfig(cfg *config.Config) error
- type Client
- func (c *Client) Close() error
- func (c *Client) GetTools() map[string]tool.InvokableTool
- func (c *Client) GetToolsForServers(serverNames []string) map[string]tool.InvokableTool
- func (c *Client) Initialize(ctx context.Context) error
- func (c *Client) ServerErrors() map[string]error
- func (c *Client) ToolCountsByServer() map[string]int
- type MCPError
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) Done() <-chan struct{}
- func (m *Manager) GetAllTools() map[string]tool.InvokableTool
- func (m *Manager) GetToolsForAgent(agentName string) ([]tool.InvokableTool, error)
- func (m *Manager) Initialize(ctx context.Context) error
- func (m *Manager) ServerErrors() map[string]error
- func (m *Manager) ToolCountsByServer() map[string]int
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMCPNotInitialized MCP manager not initialized ErrMCPNotInitialized = errors.New("MCP manager not initialized") // ErrServerNotFound MCP server not found ErrServerNotFound = errors.New("MCP server not found") // ErrToolNotFound MCP tool not found ErrToolNotFound = errors.New("MCP tool not found") // ErrInvalidConfig Invalid MCP configuration ErrInvalidConfig = errors.New("Invalid MCP configuration") // ErrConnectionFailed MCP connection failed ErrConnectionFailed = errors.New("MCP connection failed") )
MCP related error definitions
Functions ¶
func CloseGlobalManager ¶
func CloseGlobalManager() error
CloseGlobalManager closes the global MCP manager
func GetAgentMCPServers ¶
GetAgentMCPServers gets MCP server list for specified agent
func GetServerConfig ¶
GetServerConfig gets configuration for specified server
func InitializeGlobalManager ¶
InitializeGlobalManager initializes the global MCP manager
func IsConfigError ¶
IsConfigError checks if it's a configuration error
func IsConnectionError ¶
IsConnectionError checks if it's a connection error
func ShortError ¶ added in v0.5.1
ShortError renders the innermost cause of an error chain on a single line.
MCP wraps failures several layers deep ("MCP error [initialize] server:grep - failed to discover ... : net/http: TLS handshake timeout"); a user-facing notice only needs the part that says what actually went wrong, and a TUI transcript needs it without embedded newlines.
func ValidateConfig ¶
ValidateConfig validates a complete MCP configuration, including every server's own settings. It answers "is this configuration correct?".
Runtime initialization deliberately does not use it: Client.Initialize validates per server so one broken or unreachable entry cannot block the servers that work. Use ValidateConfig for diagnostics and configuration editing, not as a gate in front of connecting.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client MCP client structure
func (*Client) GetTools ¶
func (c *Client) GetTools() map[string]tool.InvokableTool
GetTools gets all available MCP tools
func (*Client) GetToolsForServers ¶
func (c *Client) GetToolsForServers(serverNames []string) map[string]tool.InvokableTool
GetToolsForServers gets tools from specified MCP servers
func (*Client) Initialize ¶
Initialize initializes the MCP client.
Servers are set up one by one. A server that cannot be reached (a dead endpoint, a TLS handshake timeout, a missing command) is recorded in ServerErrors and skipped, so its failure never removes the tools of the servers that do work. An error is returned only when nothing is left to use, which keeps a fully broken configuration visible.
func (*Client) ServerErrors ¶ added in v0.5.1
ServerErrors returns the servers that could not be initialized, mapped to the reason. An empty map means every configured server is usable.
func (*Client) ToolCountsByServer ¶ added in v0.2.0
ToolCountsByServer returns the number of discovered tools per server.
type MCPError ¶
type MCPError struct {
Op string // Operation name
Server string // Server name
Tool string // Tool name
Err error // Original error
}
MCPError MCP error wrapper
func NewMCPError ¶
NewMCPError creates new MCP error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager MCP manager, responsible for managing all MCP clients and tools
func GetGlobalManager ¶
func GetGlobalManager() *Manager
GetGlobalManager gets the global MCP manager
func WaitGlobalManager ¶ added in v0.5.1
WaitGlobalManager waits until the global manager exists and its background initialization finished, then returns it. It returns nil when ctx ends first, which lets a front-end proceed with built-in tools only.
Callers surface the result through their own interface: while a TUI owns the terminal, writing the outcome to stderr would paint over the frame.
func (*Manager) Done ¶ added in v0.5.1
func (m *Manager) Done() <-chan struct{}
Done is closed when initialization finished, successfully or not.
func (*Manager) GetAllTools ¶
func (m *Manager) GetAllTools() map[string]tool.InvokableTool
GetAllTools gets all MCP tools
func (*Manager) GetToolsForAgent ¶
func (m *Manager) GetToolsForAgent(agentName string) ([]tool.InvokableTool, error)
GetToolsForAgent gets MCP tools for specified agent
func (*Manager) Initialize ¶
Initialize initializes the MCP manager
func (*Manager) ServerErrors ¶ added in v0.5.1
ServerErrors returns the servers that could not be initialized and why. An empty map means every configured server is usable this session.
func (*Manager) ToolCountsByServer ¶ added in v0.2.0
ToolCountsByServer returns the number of discovered tools per server. It reports an empty map when the manager has not been initialized.