mcp

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 18 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 CloseGlobalManager

func CloseGlobalManager() error

CloseGlobalManager closes the global MCP manager

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 InitializeGlobalManager

func InitializeGlobalManager(ctx context.Context, cfg *config.Config) error

InitializeGlobalManager initializes the global MCP manager

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 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) 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

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

Initialize initializes the MCP client

func (*Client) ToolCountsByServer added in v0.2.0

func (c *Client) ToolCountsByServer() map[string]int

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

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

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 NewManager

func NewManager(cfg *config.Config) *Manager

NewManager creates a new MCP manager

func (*Manager) Close

func (m *Manager) Close() error

Close closes the MCP manager

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

func (m *Manager) Initialize(ctx context.Context) error

Initialize initializes the MCP manager

func (*Manager) ToolCountsByServer added in v0.2.0

func (m *Manager) ToolCountsByServer() map[string]int

ToolCountsByServer returns the number of discovered tools per server. It reports an empty map when the manager has not been initialized.

Directories

Path Synopsis
Package mcpserver exposes Oni3 agent tools through the Model Context Protocol.
Package mcpserver exposes Oni3 agent tools through the Model Context Protocol.

Jump to

Keyboard shortcuts

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