clients

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 13 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 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

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

Variables

View Source
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 Available

func Available(client string) bool

Available reports whether a client is installed.

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 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 GitRoot

func GitRoot() string

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

func Label added in v0.3.0

func Label(name string) string

Label returns a client's display name ("Claude Code"), or name itself for an unknown client.

func Labels added in v0.3.0

func Labels(conj string) string

Labels lists every client's display name for a sentence, joining the last two with conj: "Claude Code or Codex".

func Names added in v0.3.0

func Names(conj string) string

Names is Labels with client names: "claude or codex".

func Register

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

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

func Unregister(client, name, scope string) error

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.

func Get added in v0.3.0

func Get(name string) Client

Get returns the client called name, or nil.

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.

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.

Jump to

Keyboard shortcuts

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