Documentation
¶
Overview ¶
Package clients registers MCP servers with Claude Code and Codex, and reads back what each client currently has configured.
Claude registrations go through `claude mcp add-json`. Codex's are written to its config.toml directly, editing only toolshed's keys, because `codex mcp add` resets the whole server table (and can't set a headers helper). Detection reads the config files directly because it's ~1000x faster than `claude mcp list`, which health-checks every server.
Index ¶
- Constants
- Variables
- func Available(client string) bool
- func AvailableClients() []string
- func CodexHome() string
- func CodexTrusts() bool
- func Detect() map[string]*Installation
- func GitRoot() string
- func Register(client, name string, cfg Config, scope string) error
- func Unregister(client, name, scope string) error
- type Config
- type Installation
Constants ¶
const ( Claude = "claude" Codex = "codex" )
Variables ¶
var All = []string{Claude, Codex}
All lists supported clients in display order.
Functions ¶
func AvailableClients ¶
func AvailableClients() []string
AvailableClients returns the installed clients, in display order.
func CodexTrusts ¶ added in v0.2.0
func CodexTrusts() bool
CodexTrusts reports whether Codex trusts the current repository. Codex ignores a project's .codex/config.toml until the user trusts it.
func Detect ¶
func Detect() map[string]*Installation
Detect returns every server registered in Claude Code or Codex, keyed by name. Codex names with underscores are also folded into their hyphen form when nothing else has that name, because toolshed used to register "my-tool" as "my_tool" in Codex. Unreadable or missing config files are treated as empty.
func Register ¶
Register adds (or replaces) a server in one client at a scope: Claude takes "user", "local" or "project"; Codex takes "user" or "project".
Claude: remove-then-add through `claude mcp add-json`, carrying over any keys toolshed doesn't model (a "timeout", say). If the add fails, the previous registration is put back. Codex: its config.toml is edited in place (see codextoml.go), which never leaves it half-written.
func Unregister ¶
Unregister removes a server from one client at a scope.
Types ¶
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.
type Installation ¶
type Installation struct {
Name string
ClaudeScope string // "user", "project", "local", or "" when not in Claude
Codex bool
CodexScope string // "user" ($CODEX_HOME/config.toml) or "project" (<repo>/.codex/config.toml)
CodexName string // the key in Codex's config (older toolshed wrote "my_tool" for "my-tool")
Config Config // Claude's config if present, else Codex's
CodexConfig Config // Codex's own config, when Codex has it
// contains filtered or unexported fields
}
Installation is where one server name is registered.
func (Installation) Clients ¶
func (i Installation) Clients() []string
Clients returns the clients this server is registered in.
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.