manager

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package manager provides multi-server orchestration for MCP clients.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package manager provides multi-server orchestration for MCP clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfo

type ClientInfo struct {
	Name    string `yaml:"name" json:"name"`
	Version string `yaml:"version" json:"version"`
}

ClientInfo provides implementation details sent to MCP servers.

type Config

type Config struct {
	// Servers maps server name to server configuration
	Servers map[string]ServerConfig `yaml:"servers" json:"servers"`

	// DynamicDiscovery enables runtime tool discovery
	DynamicDiscovery DynamicDiscoveryConfig `yaml:"dynamic_discovery" json:"dynamic_discovery"`

	// ClientInfo provides implementation details sent to MCP servers
	ClientInfo ClientInfo `yaml:"client_info" json:"client_info"`
}

Config defines the configuration for the MCP manager.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a default configuration.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the configuration for errors.

type DynamicDiscoveryConfig

type DynamicDiscoveryConfig struct {
	// Enabled enables dynamic tool discovery
	Enabled bool `yaml:"enabled" json:"enabled"`

	// CacheSize is the maximum number of discovered tools to cache
	CacheSize int `yaml:"cache_size" json:"cache_size"`
}

DynamicDiscoveryConfig configures runtime tool discovery.

type Manager

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

Manager orchestrates multiple MCP server connections.

func NewManager

func NewManager(config Config, logger *zap.Logger) (*Manager, error)

NewManager creates a new MCP manager.

func (*Manager) AddServer

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

AddServer dynamically adds and starts a new MCP server.

func (*Manager) GetClient

func (m *Manager) GetClient(serverName string) (*client.Client, error)

GetClient returns a client by server name.

func (*Manager) GetServerConfig

func (m *Manager) GetServerConfig(serverName string) (ServerConfig, error)

GetServerConfig returns the configuration for a server.

func (*Manager) HealthCheck

func (m *Manager) HealthCheck(ctx context.Context) map[string]bool

HealthCheck checks the health of all servers.

func (*Manager) IsHealthy

func (m *Manager) IsHealthy(ctx context.Context, serverName string) bool

IsHealthy checks if a server is healthy by pinging it.

func (*Manager) ListServers

func (m *Manager) ListServers() []ServerInfo

ListServers returns information about all servers.

func (*Manager) RemoveServer

func (m *Manager) RemoveServer(name string) error

RemoveServer stops and completely removes a server from the manager. This removes the server from both the clients map and the config.

func (*Manager) ServerNames

func (m *Manager) ServerNames() []string

ServerNames returns a list of all active server names.

func (*Manager) Start

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

Start initializes connections to all enabled servers.

func (*Manager) Stop

func (m *Manager) Stop() error

Stop closes all server connections.

func (*Manager) StopServer

func (m *Manager) StopServer(name string) error

StopServer stops a specific MCP server.

type ServerConfig

type ServerConfig struct {
	// Enabled indicates whether this server should be started
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Command is the executable to run for stdio transport
	Command string `yaml:"command" json:"command"`

	// Args are the command-line arguments for the command
	Args []string `yaml:"args" json:"args"`

	// Env are environment variables to set for the subprocess
	Env map[string]string `yaml:"env" json:"env"`

	// ToolFilter controls which tools are registered from this server
	ToolFilter ToolFilter `yaml:"tools" json:"tools"`

	// Transport specifies the transport type ("stdio" or "sse")
	Transport string `yaml:"transport" json:"transport"`

	// URL is the server URL (for SSE transport)
	URL string `yaml:"url" json:"url"`

	// Timeout for server operations (e.g., "30s", "1m")
	Timeout string `yaml:"timeout" json:"timeout"`
}

ServerConfig defines the configuration for a single MCP server.

func (*ServerConfig) Validate

func (s *ServerConfig) Validate() error

Validate checks the server configuration for errors.

type ServerInfo

type ServerInfo struct {
	Name      string
	Enabled   bool
	Connected bool
	Transport string
}

ServerInfo provides information about a server.

type ToolFilter

type ToolFilter struct {
	// All indicates whether to register all tools (default: false)
	All bool `yaml:"all" json:"all"`

	// Include is a whitelist of tool names (if set, only these are registered)
	Include []string `yaml:"include" json:"include"`

	// Exclude is a blacklist of tool names (applied after include)
	Exclude []string `yaml:"exclude" json:"exclude"`
}

ToolFilter controls which tools are registered from a server.

func (*ToolFilter) ShouldRegisterTool

func (f *ToolFilter) ShouldRegisterTool(toolName string) bool

ShouldRegisterTool checks if a tool should be registered based on the filter.

Jump to

Keyboard shortcuts

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