Documentation
¶
Overview ¶
Package client provides utilities for managing client configurations and interacting with MCP servers.
Index ¶
- Variables
- func CheckAndPerformAutoDiscoveryMigration()
- func GenerateMCPServerURL(transportType string, host string, port int, containerName string) string
- 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
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 GenerateMCPServerURL ¶
GenerateMCPServerURL generates the URL for an MCP server
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() ([]ConfigFile, error)
FindRegisteredClientConfigs searches for client configuration files for registered clients in standard locations
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" )
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() ([]MCPClientStatus, error)
GetClientStatus returns the installation status of all supported MCP clients
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. ListClients() ([]Client, error) // RegisterClients registers multiple clients with ToolHive. RegisterClients(ctx context.Context, clients []Client) error // UnregisterClients unregisters multiple clients from ToolHive. UnregisterClients(ctx context.Context, clients []Client) error }
Manager is the interface for managing registered ToolHive clients.