clients

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	Claude = "claude"
	Codex  = "codex"
)

Variables

View Source
var All = []string{Claude, Codex}

All lists supported clients in display order.

Functions

func Available

func Available(client string) bool

Available reports whether a client's CLI is on PATH.

func AvailableClients

func AvailableClients() []string

AvailableClients returns the installed clients, in display order.

func CodexHome added in v0.2.0

func CodexHome() string

CodexHome is $CODEX_HOME, or ~/.codex.

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 GitRoot

func GitRoot() string

GitRoot returns the current git repository root, or "".

func Register

func Register(client, name string, cfg Config, scope string) error

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

func Unregister(client, name, scope string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL