Documentation
¶
Overview ¶
Package desktopconfig reads, updates, and writes Claude Desktop's MCP server config file (claude_desktop_config.json) atomically and without clobbering unrelated entries.
Index ¶
- Constants
- Variables
- func DefaultClaudeDesktopPath() (string, error)
- func HasServer(path, name string) (bool, error)
- func HasServerInKey(path, key, name string) (bool, error)
- func RemoveServer(path, name string) error
- func RemoveServerInKey(path, key, name string) error
- func UpsertServer(path, name string, server any) error
- func UpsertServerInKey(path, key, name string, server any) error
- type RemoteServer
- type StdioServer
Constants ¶
const DefaultServersKey = "mcpServers"
DefaultServersKey is the standard top-level key used by Claude Desktop, Claude Code, Cursor, and most other MCP-aware tools. VS Code uses "servers" instead — callers writing a VS Code config must pass that explicitly via the *InKey variants.
Variables ¶
var ErrUnsupportedOS = errors.New("Claude Desktop is not available on this OS; use --client print")
ErrUnsupportedOS indicates Claude Desktop is not available on the current OS.
Functions ¶
func DefaultClaudeDesktopPath ¶
DefaultClaudeDesktopPath returns the per-OS path to Claude Desktop's config.
func HasServerInKey ¶ added in v0.3.0
HasServerInKey returns true if the named entry exists under the given key.
func RemoveServer ¶
RemoveServer removes the named entry from "mcpServers". No-op if the file or entry is absent.
func RemoveServerInKey ¶ added in v0.3.0
RemoveServerInKey removes the named entry from the given top-level key. No-op if the file, key, or entry is absent.
func UpsertServer ¶
UpsertServer reads the JSON file at path (creating it if absent), inserts or updates the named MCP server entry under "mcpServers", and writes the result atomically (temp file + rename). All other top-level keys and sibling server entries are preserved.
server can be any JSON-marshalable value; in practice either RemoteServer (HTTP) or StdioServer (stdio bridge). The caller picks the shape; this function does not validate it.
func UpsertServerInKey ¶ added in v0.3.0
UpsertServerInKey is the generalised form of UpsertServer that lets the caller pick the top-level JSON key. VS Code's MCP config uses "servers"; every other supported client uses "mcpServers" (see DefaultServersKey).
Types ¶
type RemoteServer ¶
type RemoteServer struct {
Type string `json:"type,omitempty"`
URL string `json:"url"`
Headers map[string]string `json:"headers,omitempty"`
}
RemoteServer matches the JSON shape Claude Desktop expects for HTTP MCP servers, per docs/mcp/remote-setup.md.
type StdioServer ¶ added in v0.2.1
StdioServer matches the JSON shape Claude Desktop expects for a stdio MCP server: a subprocess invocation. The CLI uses this to install itself as a bridge (`taufinity mcp stdio`), which Claude Desktop launches and which forwards JSON-RPC frames to Studio's /mcp endpoint. The bearer token is NOT embedded — the bridge subprocess reads credentials.json at startup.