mcp

package
v0.12.21 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dedup added in v0.12.9

func Dedup(servers map[string]ServerConfig, preferred []string) []string

Dedup removes servers that are configured identically to one already kept, so the same endpoint is not connected twice and its tools are not offered under two names. Only a complete match collapses: one differing header or environment variable is a deliberate distinction and keeps both alive.

preferred lists names in precedence order and decides which name survives; any remaining name is considered afterwards in sorted order.

Types

type Config

type Config struct {
	Servers map[string]ServerConfig `json:"mcpServers"`
}

type ElicitFunc added in v0.10.1

type ElicitFunc func(ctx context.Context, req tool.ElicitRequest) (tool.ElicitResult, error)

type Manager

type Manager struct {
	*Config

	Dir string
	// contains filtered or unexported fields
}

func Load

func Load(paths ...string) (*Manager, error)

func NewManager

func NewManager(cfg *Config) *Manager

func (*Manager) AddServer

func (m *Manager) AddServer(ctx context.Context, name string, server ServerConfig) error

func (*Manager) AddSession

func (m *Manager) AddSession(name string, session *mcp.ClientSession)

func (*Manager) Close

func (m *Manager) Close()

func (*Manager) Connect

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

func (*Manager) Session added in v0.12.7

func (m *Manager) Session(name string) *mcp.ClientSession

func (*Manager) Sessions

func (m *Manager) Sessions() map[string]*mcp.ClientSession

func (*Manager) SetElicit added in v0.10.1

func (m *Manager) SetElicit(fn ElicitFunc)

SetElicit routes elicitation/create requests from connected MCP servers to the given UI surface. A nil handler declines all requests.

func (*Manager) SetToolListChangedHandler added in v0.12.7

func (m *Manager) SetToolListChangedHandler(handler ToolListChangedFunc)

type ServerConfig

type ServerConfig struct {
	Transport string `json:"transport,omitempty"`

	URL string `json:"url,omitempty"`

	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`

	Headers map[string]string `json:"headers,omitempty"`

	// Dir overrides the manager-wide working directory for this server alone.
	// Plugin-provided servers run in their own package or data directory.
	Dir string `json:"-"`
}

type ToolListChangedFunc added in v0.12.7

type ToolListChangedFunc func(serverName string)

Jump to

Keyboard shortcuts

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