mcp

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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