desktopconfig

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

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

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

func DefaultClaudeDesktopPath() (string, error)

DefaultClaudeDesktopPath returns the per-OS path to Claude Desktop's config.

func HasServer

func HasServer(path, name string) (bool, error)

HasServer returns true if the named entry exists in "mcpServers".

func HasServerInKey added in v0.3.0

func HasServerInKey(path, key, name string) (bool, error)

HasServerInKey returns true if the named entry exists under the given key.

func RemoveServer

func RemoveServer(path, name string) error

RemoveServer removes the named entry from "mcpServers". No-op if the file or entry is absent.

func RemoveServerInKey added in v0.3.0

func RemoveServerInKey(path, key, name string) error

RemoveServerInKey removes the named entry from the given top-level key. No-op if the file, key, or entry is absent.

func UpsertServer

func UpsertServer(path, name string, server any) error

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

func UpsertServerInKey(path, key, name string, server any) error

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

type StdioServer struct {
	Command string   `json:"command"`
	Args    []string `json:"args,omitempty"`
}

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.

Jump to

Keyboard shortcuts

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