Documentation
¶
Overview ¶
Package client provides utilities for managing client configurations and interacting with MCP servers.
Index ¶
- Variables
- func CheckAndPerformAutoDiscoveryMigration()
- func Upsert(cf ConfigFile, name string, url string, transportType string) error
- type Client
- type ConfigFile
- type ConfigUpdater
- type Extension
- type JSONConfigUpdater
- type MCPClient
- type MCPClientStatus
- type MCPServer
- type MCPServerConfig
- type Manager
- type RegisteredClient
Constants ¶
This section is empty.
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 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.
const ( // JSON represents a JSON extension. JSON Extension = "json" )
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" )
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 installation status of all supported MCP clients
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.
type RegisteredClient ¶ added in v0.2.8
RegisteredClient represents a registered client with its associated groups.