mcp

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 GetAgentMCPServers

func GetAgentMCPServers(cfg *config.Config, agentName string) ([]string, error)

GetAgentMCPServers gets MCP server list for specified agent

func GetServerConfig

func GetServerConfig(cfg *config.Config, serverName string) (*config.MCPServer, error)

GetServerConfig gets configuration for specified server

func IsConfigError

func IsConfigError(err error) bool

IsConfigError checks if it's a configuration error

func IsConnectionError

func IsConnectionError(err error) bool

IsConnectionError checks if it's a connection error

func ValidateConfig

func ValidateConfig(cfg *config.Config) error

ValidateConfig validates MCP configuration

Types

type ApprovalInfo

type ApprovalInfo struct {
	ToolName        string
	ArgumentsInJSON string
	ToolCallID      string
}

func (*ApprovalInfo) String

func (ai *ApprovalInfo) String() string

type ApprovalResult

type ApprovalResult struct {
	Approved         bool
	DisapproveReason *string
}

type Client

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

Client MCP client structure

func NewClient

func NewClient(cfg *config.Config) *Client

NewClient creates a new MCP client

func (*Client) Close

func (c *Client) Close() error

Close closes all MCP client connections

func (*Client) GetToolList

func (c *Client) GetToolList() []tool.BaseTool

func (*Client) GetToolListForServers

func (c *Client) GetToolListForServers(serverNames []string) []tool.BaseTool

func (*Client) GetTools

func (c *Client) GetTools() map[string]tool.BaseTool

GetTools gets all available MCP tools

func (*Client) GetToolsForServers

func (c *Client) GetToolsForServers(serverNames []string) map[string]tool.BaseTool

GetToolsForServers gets tools from specified MCP servers

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context) error

Initialize initializes the MCP client

func (*Client) InitializeForChat

func (c *Client) InitializeForChat(ctx context.Context, chat config.Chat) error

type InvokableApprovableTool

type InvokableApprovableTool struct {
	tool.InvokableTool
}

func (InvokableApprovableTool) Info

func (InvokableApprovableTool) InvokableRun

func (i InvokableApprovableTool) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error)

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

func NewMCPError(op, server, tool string, err error) *MCPError

NewMCPError creates new MCP error

func (*MCPError) Error

func (e *MCPError) Error() string

Error implements error interface

func (*MCPError) Unwrap

func (e *MCPError) Unwrap() error

Unwrap returns original error

Jump to

Keyboard shortcuts

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