mcp

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransportStdio   = "stdio"
	TransportHTTPSSE = "http_sse"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	ListTools(ctx context.Context) ([]ToolDefinition, error)
	CallTool(ctx context.Context, toolName, argsJSON string) (any, error)
}

Client is the MCP client abstraction used by the manager.

type Connector

type Connector interface {
	Connect(ctx context.Context, serverName string, cfg config.MCPServerConfig) (Client, error)
}

Connector dials a server and returns a client implementation.

type Connectors

type Connectors struct {
	Stdio   Connector
	HTTPSSE Connector
}

Connectors groups supported transport connectors.

func DefaultConnectors

func DefaultConnectors() Connectors

DefaultConnectors returns production connectors for stdio and HTTP/SSE transports.

type Manager

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

Manager owns configured MCP servers and dynamic tool registration.

func NewManager

func NewManager(servers map[string]config.MCPServerConfig, connectors Connectors) *Manager

NewManager constructs a manager from config.MCP.Servers.

func (*Manager) CallTool

func (m *Manager) CallTool(ctx context.Context, serverName, toolName, argsJSON string) (string, error)

CallTool routes a raw tool call to the selected MCP server client. When the server is degraded or a tool call fails, CallTool attempts bounded reconnect with backoff.

func (*Manager) Connect

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

Connect discovers tools from each configured server. Failures are tracked as degraded states and do not fail the entire manager.

func (*Manager) RegisterTools

func (m *Manager) RegisterTools(reg *tools.Registry) error

RegisterTools registers discovered MCP tools into the given registry.

func (*Manager) Statuses

func (m *Manager) Statuses() []ServerStatus

Statuses returns per-server connection/discovery status.

type ServerStatus

type ServerStatus struct {
	Name      string
	Transport string
	Connected bool
	Degraded  bool
	ToolCount int
	Message   string
}

ServerStatus represents current manager state for one configured server.

type ToolDefinition

type ToolDefinition struct {
	Name        string
	Description string
}

ToolDefinition describes a tool discovered from an MCP server.

Jump to

Keyboard shortcuts

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