Documentation
¶
Overview ¶
Package client provides utilities for managing client configurations and interacting with MCP servers.
Index ¶
- Constants
- Variables
- func CheckAndPerformAutoDiscoveryMigration()
- func Upsert(cf ConfigFile, name string, url string, transportType string) error
- type Client
- type ClientManager
- func (cm *ClientManager) CreateClientConfig(clientType MCPClient) (*ConfigFile, error)
- func (cm *ClientManager) FindClientConfig(clientType MCPClient) (*ConfigFile, error)
- func (cm *ClientManager) FindRegisteredClientConfigs(ctx context.Context) ([]ConfigFile, error)
- func (cm *ClientManager) GetClientStatus(ctx context.Context) ([]MCPClientStatus, error)
- func (cm *ClientManager) Upsert(cf ConfigFile, name string, url string, transportType string) error
- type ConfigFile
- type ConfigUpdater
- type Extension
- type GooseConfig
- type GooseExtension
- type GooseYAMLConverter
- type JSONConfigUpdater
- type MCPClient
- type MCPClientStatus
- type MCPServer
- type MCPServerConfig
- type Manager
- type RegisteredClient
- type YAMLConfigUpdater
- type YAMLConverter
Constants ¶
const (
// GooseTimeout is the Goose operation timeout in seconds
GooseTimeout = 60
)
Variables ¶
var ( // ErrConfigFileNotFound is returned when a client configuration file is not found ErrConfigFileNotFound = fmt.Errorf("client config file not found") )
Functions ¶
func CheckAndPerformAutoDiscoveryMigration ¶ added in v0.1.0
func CheckAndPerformAutoDiscoveryMigration()
CheckAndPerformAutoDiscoveryMigration checks if auto-discovery migration is needed and performs it This is called once at application startup
func Upsert ¶ added in v0.0.32
func Upsert(cf ConfigFile, name string, url string, transportType string) error
Upsert updates/inserts an MCP server in a client configuration file It is a wrapper around the ConfigUpdater.Upsert method. Because the ConfigUpdater is different for each client type, we need to handle the different types of McpServer objects. For example, VSCode and ClaudeCode allows for a `type` field, but Cursor and others do not. This allows us to build up more complex MCP server configurations for different clients without leaking them into the CMD layer.
Types ¶
type Client ¶ added in v0.0.43
type Client struct {
Name MCPClient `json:"name"`
}
Client represents a registered ToolHive client.
type ClientManager ¶ added in v0.2.14
type ClientManager struct {
// contains filtered or unexported fields
}
ClientManager encapsulates dependencies for client operations
func NewClientManager ¶ added in v0.2.14
func NewClientManager() (*ClientManager, error)
NewClientManager creates a new ClientManager with default dependencies
func NewTestClientManager ¶ added in v0.2.14
func NewTestClientManager( homeDir string, groupManager groups.Manager, clientIntegrations []mcpClientConfig, configProvider config.Provider, ) *ClientManager
NewTestClientManager creates a new ClientManager with test dependencies
func (*ClientManager) CreateClientConfig ¶ added in v0.2.14
func (cm *ClientManager) CreateClientConfig(clientType MCPClient) (*ConfigFile, error)
CreateClientConfig creates a new client configuration file for a given client type using this manager's dependencies.
func (*ClientManager) FindClientConfig ¶ added in v0.2.14
func (cm *ClientManager) FindClientConfig(clientType MCPClient) (*ConfigFile, error)
FindClientConfig returns the client configuration file for a given client type using this manager's dependencies.
func (*ClientManager) FindRegisteredClientConfigs ¶ added in v0.2.14
func (cm *ClientManager) FindRegisteredClientConfigs(ctx context.Context) ([]ConfigFile, error)
FindRegisteredClientConfigs finds all registered client configs using this manager's dependencies
func (*ClientManager) GetClientStatus ¶ added in v0.2.14
func (cm *ClientManager) GetClientStatus(ctx context.Context) ([]MCPClientStatus, error)
GetClientStatus returns the status of all supported MCP clients using this manager's dependencies
func (*ClientManager) Upsert ¶ added in v0.2.14
func (cm *ClientManager) Upsert(cf ConfigFile, name string, url string, transportType string) error
Upsert updates/inserts an MCP server in a client configuration file using this manager's dependencies.
type ConfigFile ¶
type ConfigFile struct { Path string ClientType MCPClient ConfigUpdater ConfigUpdater Extension Extension }
ConfigFile represents a client configuration file
func CreateClientConfig ¶ added in v0.1.0
func CreateClientConfig(clientType MCPClient) (*ConfigFile, error)
CreateClientConfig creates a new client configuration file for a given client type.
func FindClientConfig ¶ added in v0.0.43
func FindClientConfig(clientType MCPClient) (*ConfigFile, error)
FindClientConfig returns the client configuration file for a given client type.
func FindRegisteredClientConfigs ¶ added in v0.1.3
func FindRegisteredClientConfigs(ctx context.Context) ([]ConfigFile, error)
FindRegisteredClientConfigs finds all registered client configs and creates them if they don't exist.
type ConfigUpdater ¶ added in v0.0.32
type ConfigUpdater interface { Upsert(serverName string, data MCPServer) error Remove(serverName string) error }
ConfigUpdater defines the interface for types which can edit MCP client config files.
type Extension ¶ added in v0.0.32
type Extension string
Extension is extension of the client config file.
type GooseConfig ¶ added in v0.3.0
type GooseConfig struct {
Extensions map[string]GooseExtension `yaml:"extensions"`
}
GooseConfig represents the structure of Goose's config.yaml
type GooseExtension ¶ added in v0.3.0
type GooseExtension struct { Name string `yaml:"name"` Enabled bool `yaml:"enabled"` Type string `yaml:"type"` Timeout int `yaml:"timeout,omitempty"` Uri string `yaml:"uri,omitempty"` }
GooseExtension represents an extension in Goose's config.yaml format
type GooseYAMLConverter ¶ added in v0.3.0
type GooseYAMLConverter struct{}
GooseYAMLConverter implements YAMLConverter for Goose config format
func (*GooseYAMLConverter) ConvertFromMCPServer ¶ added in v0.3.0
func (*GooseYAMLConverter) ConvertFromMCPServer(serverName string, server MCPServer) (interface{}, error)
ConvertFromMCPServer converts an MCPServer to a GooseExtension
func (*GooseYAMLConverter) RemoveEntry ¶ added in v0.3.0
func (*GooseYAMLConverter) RemoveEntry(config interface{}, serverName string) error
RemoveEntry removes a server entry from the config map
func (*GooseYAMLConverter) UpsertEntry ¶ added in v0.3.0
func (*GooseYAMLConverter) UpsertEntry(config interface{}, serverName string, entry interface{}) error
UpsertEntry adds or updates a server entry in the config map
type JSONConfigUpdater ¶ added in v0.0.32
JSONConfigUpdater is a ConfigUpdater that is responsible for updating JSON config files.
func (*JSONConfigUpdater) Remove ¶ added in v0.0.32
func (jcu *JSONConfigUpdater) Remove(serverName string) error
Remove removes an MCP server from the MCP client config file
type MCPClient ¶
type MCPClient string
MCPClient is an enum of supported MCP clients.
const ( // RooCode represents the Roo Code extension for VS Code. RooCode MCPClient = "roo-code" // Cline represents the Cline extension for VS Code. Cline MCPClient = "cline" // Cursor represents the Cursor editor. Cursor MCPClient = "cursor" // VSCodeInsider represents the VS Code Insiders editor. VSCodeInsider MCPClient = "vscode-insider" // VSCode represents the standard VS Code editor. VSCode MCPClient = "vscode" // ClaudeCode represents the Claude Code CLI. ClaudeCode MCPClient = "claude-code" // Windsurf represents the Windsurf IDE. Windsurf MCPClient = "windsurf" // WindsurfJetBrains represents the Windsurf plugin for JetBrains. WindsurfJetBrains MCPClient = "windsurf-jetbrains" // AmpCli represents the Sourcegraph Amp CLI. AmpCli MCPClient = "amp-cli" // AmpVSCode represents the Sourcegraph Amp extension for VS Code. AmpVSCode MCPClient = "amp-vscode" // AmpCursor represents the Sourcegraph Amp extension for Cursor. AmpCursor MCPClient = "amp-cursor" // AmpVSCodeInsider represents the Sourcegraph Amp extension for VS Code Insiders. AmpVSCodeInsider MCPClient = "amp-vscode-insider" // AmpWindsurf represents the Sourcegraph Amp extension for Windsurf. AmpWindsurf MCPClient = "amp-windsurf" // LMStudio represents the LM Studio application. LMStudio MCPClient = "lm-studio" // Goose represents the Goose AI agent. Goose MCPClient = "goose" )
type MCPClientStatus ¶ added in v0.0.41
type MCPClientStatus struct { // ClientType is the type of MCP client ClientType MCPClient `json:"client_type"` // Installed indicates whether the client is installed on the system Installed bool `json:"installed"` // Registered indicates whether the client is registered in the ToolHive configuration Registered bool `json:"registered"` }
MCPClientStatus represents the status of a supported MCP client
func GetClientStatus ¶ added in v0.0.41
func GetClientStatus(ctx context.Context) ([]MCPClientStatus, error)
GetClientStatus returns the status of all supported MCP clients using the default config provider
func GetClientStatusWithDependencies ¶ added in v0.2.14
func GetClientStatusWithDependencies( ctx context.Context, configProvider config.Provider, homeDir string, groupManager groups.Manager, clientIntegrations []mcpClientConfig, ) ([]MCPClientStatus, error)
GetClientStatusWithDependencies returns the status of all supported MCP clients using provided dependencies
type MCPServer ¶ added in v0.0.32
type MCPServer struct { Url string `json:"url,omitempty"` ServerUrl string `json:"serverUrl,omitempty"` Type string `json:"type,omitempty"` }
MCPServer represents an MCP server in a MCP client config file
type MCPServerConfig ¶
type MCPServerConfig struct {
URL string `json:"url,omitempty"`
}
MCPServerConfig represents an MCP server configuration in a client config file
type Manager ¶ added in v0.0.43
type Manager interface { // ListClients returns a list of all registered clients with their group information. ListClients(ctx context.Context) ([]RegisteredClient, error) // RegisterClients registers multiple clients with ToolHive for the specified workloads. RegisterClients(clients []Client, workloads []core.Workload) error // UnregisterClients unregisters multiple clients from ToolHive for the specified workloads. UnregisterClients(ctx context.Context, clients []Client, workloads []core.Workload) error // AddServerToClients adds an MCP server to the appropriate client configurations. AddServerToClients(ctx context.Context, serverName, serverURL, transportType, group string) error // RemoveServerFromClients removes an MCP server from the appropriate client configurations. RemoveServerFromClients(ctx context.Context, serverName, group string) error }
Manager is the interface for managing registered ToolHive clients.
func NewManager ¶ added in v0.0.43
NewManager creates a new client manager instance.
type RegisteredClient ¶ added in v0.2.8
RegisteredClient represents a registered client with its associated groups.
type YAMLConfigUpdater ¶ added in v0.3.0
type YAMLConfigUpdater struct { Path string Converter YAMLConverter }
YAMLConfigUpdater is a ConfigUpdater that is responsible for updating YAML config files using a converter interface for flexibility.
func (*YAMLConfigUpdater) Remove ¶ added in v0.3.0
func (ycu *YAMLConfigUpdater) Remove(serverName string) error
Remove removes an entry from the config.yaml file using the converter
type YAMLConverter ¶ added in v0.3.0
type YAMLConverter interface { ConvertFromMCPServer(serverName string, server MCPServer) (interface{}, error) UpsertEntry(config interface{}, serverName string, entry interface{}) error RemoveEntry(config interface{}, serverName string) error }
YAMLConverter defines an interface for converting MCPServer data to different YAML config formats