Documentation
¶
Overview ¶
Package clients registers MCP servers with the clients toolshed supports (Claude Code, Codex and Antigravity), and reads back what each one currently has configured.
Each client is an adapter (claude.go, codex.go, antigravity.go) behind the Client interface. Everything outside this package works with client names and the neutral Config, so supporting another client means adding an adapter here.
Detection reads the config files directly because it's ~1000x faster than `claude mcp list`, which health-checks every server.
Index ¶
- Constants
- Variables
- func AntigravityConfig() string
- func Available(client string) bool
- func AvailableClients() []string
- func CodexHome() string
- func Detect() map[string]*Installation
- func GitRoot() string
- func Label(name string) string
- func Labels(conj string) string
- func Names(conj string) string
- func Register(client, name string, cfg Config, scope string) error
- func Unregister(client, name, scope string) error
- type Client
- type Config
- type Installation
- type Registration
Constants ¶
const ( Claude = "claude" Codex = "codex" )
const Antigravity = "antigravity"
Variables ¶
var All = func() []string { var names []string for _, c := range adapters { names = append(names, c.Name()) } return names }()
All lists supported client names in display order.
Functions ¶
func AntigravityConfig ¶ added in v0.3.0
func AntigravityConfig() string
AntigravityConfig is Antigravity's MCP config file for your user.
func AvailableClients ¶
func AvailableClients() []string
AvailableClients returns the installed clients, in display order.
func Detect ¶
func Detect() map[string]*Installation
Detect returns every server registered in any client, keyed by name. Unreadable or missing config files are treated as empty.
func Label ¶ added in v0.3.0
Label returns a client's display name ("Claude Code"), or name itself for an unknown client.
func Labels ¶ added in v0.3.0
Labels lists every client's display name for a sentence, joining the last two with conj: "Claude Code or Codex".
func Register ¶
Register adds (or replaces) a server in one client at a scope, keeping the settings toolshed doesn't manage. scope is one the client has (see Client.Scope).
Registering it at another scope than the one the client uses moves it, settings and all, and removes that registration once the new one is in place, so it doesn't linger as a hidden second copy. Other copies the client already hides are left alone (doctor reports them).
func Unregister ¶
Unregister removes a server from one client at a scope, whether the client uses that registration here or not.
Types ¶
type Client ¶ added in v0.3.0
type Client interface {
Name() string // "claude": what --client, the registry and the JSON output use
Label() string // "Claude Code": what people read
// Available reports whether the client is installed on this machine.
Available() bool
// Scope maps a requested scope ("user", "local" or "project") to the
// nearest one this client has, or "" when it has none that keeps the
// server out of other projects (then it's skipped, never made global).
Scope(requested string) string
// Unsupported says why the client can't run a server registered as cfg
// (a remote server's headers from a command, say), or "".
Unsupported(cfg Config) string
// Notes are things to know after registering a server at scope.
Notes(scope string) []string
// contains filtered or unexported methods
}
Client is one MCP client toolshed can register servers with.
type Config ¶
type Config struct {
Type string `json:"type"` // "stdio" or "http"
Command string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
URL string `json:"url,omitempty"`
Headers map[string]string `json:"headers,omitempty"` // static headers (Codex: http_headers)
HeadersHelper string `json:"headersHelper,omitempty"`
// Codex only, read for import and doctor; toolshed never writes them.
BearerTokenEnvVar string `json:"-"`
EnvHeaders map[string]string `json:"-"`
}
Config is a server registration, in Claude Code's add-json shape. Each adapter translates it to and from its client's own format.
type Installation ¶
type Installation struct {
Name string
Regs map[string]Registration // by client name: the registration the client uses here
// Hidden are other registrations of the name in the same client, at
// scopes that client doesn't use here because Regs's one wins: a second
// copy, left behind or deliberate (a repository's shared config, say).
Hidden map[string][]Registration
}
Installation is where one server name is registered.
func (Installation) At ¶ added in v0.3.0
func (i Installation) At(client, scope string) (Registration, bool)
At returns the registration in client at scope, whether the client uses it here or not.
func (Installation) Clients ¶
func (i Installation) Clients() []string
Clients returns the clients this server is registered in, in display order.
func (Installation) Config ¶
func (i Installation) Config() Config
Config returns the first client's config, in display order: the one to show, and to compare the others with.
func (Installation) Configs ¶ added in v0.3.0
func (i Installation) Configs() []Config
Configs returns every client's config, in display order.
func (Installation) Has ¶ added in v0.3.0
func (i Installation) Has(client string) bool
Has reports whether the server is registered in client.
func (Installation) Scope ¶ added in v0.2.0
func (i Installation) Scope(client string) string
Scope returns the scope the server is registered at in one client, or "".
type Registration ¶ added in v0.3.0
type Registration struct {
Scope string // "user", "project", or Claude's "local"
Key string // the server's key in the client's config (older toolshed wrote Codex's "my-tool" as "my_tool")
Config Config
// contains filtered or unexported fields
}
Registration is a server as one client has it.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package clienttest helps tests check where clients have a server registered, straight from their config files.
|
Package clienttest helps tests check where clients have a server registered, straight from their config files. |