Documentation
¶
Overview ¶
Package claude provides an adapter for Claude Code / Claude Desktop MCP configuration files (.mcp.json).
Claude's format is the de-facto standard adopted by most AI assistants including Cursor, Windsurf, and Cline.
File locations (per https://code.claude.com/docs/en/mcp):
- Project scope: .mcp.json (in project root, checked into source control)
- User/Local scope: ~/.claude.json (mcpServers field, private to user)
- Enterprise managed:
- macOS: /Library/Application Support/ClaudeCode/managed-mcp.json
- Linux/WSL: /etc/claude-code/managed-mcp.json
- Windows: C:\Program Files\ClaudeCode\managed-mcp.json
Index ¶
- Constants
- func ReadProjectConfig() (*core.Config, error)
- func ReadUserConfig() (*core.Config, error)
- func WriteProjectConfig(cfg *core.Config) error
- type Adapter
- func (a *Adapter) DefaultPaths() []string
- func (a *Adapter) FromCore(cfg *core.Config) *Config
- func (a *Adapter) Marshal(cfg *core.Config) ([]byte, error)
- func (a *Adapter) Name() string
- func (a *Adapter) Parse(data []byte) (*core.Config, error)
- func (a *Adapter) ReadFile(path string) (*core.Config, error)
- func (a *Adapter) ToCore(claudeCfg *Config) *core.Config
- func (a *Adapter) WriteFile(cfg *core.Config, path string) error
- type Config
- type ServerConfig
Constants ¶
const ( // AdapterName is the identifier for this adapter. AdapterName = "claude" // ProjectConfigFile is the project-level config file name. ProjectConfigFile = ".mcp.json" // UserConfigFile is the user-level config file name. UserConfigFile = ".claude.json" // ManagedConfigFile is the enterprise managed config file name. ManagedConfigFile = "managed-mcp.json" )
Variables ¶
This section is empty.
Functions ¶
func ReadProjectConfig ¶
ReadProjectConfig reads the project-level .mcp.json file.
func ReadUserConfig ¶
ReadUserConfig reads the user-level ~/.claude.json file.
func WriteProjectConfig ¶
WriteProjectConfig writes to the project-level .mcp.json file.
Types ¶
type Adapter ¶
type Adapter struct{}
Adapter implements core.Adapter for Claude Code / Claude Desktop.
func (*Adapter) DefaultPaths ¶
DefaultPaths returns the default config file paths for Claude.
type Config ¶
type Config struct {
// MCPServers maps server names to their configurations.
MCPServers map[string]ServerConfig `json:"mcpServers"`
}
Config represents the Claude MCP configuration file format. This is the top-level structure for .mcp.json files.
func (*Config) AddServer ¶
func (c *Config) AddServer(name string, server ServerConfig)
AddServer adds a server to the configuration.
func (*Config) GetServer ¶
func (c *Config) GetServer(name string) (ServerConfig, bool)
GetServer returns a server by name.
func (*Config) RemoveServer ¶
RemoveServer removes a server from the configuration.
func (*Config) ServerNames ¶
ServerNames returns a list of all server names.
type ServerConfig ¶
type ServerConfig struct {
// Type specifies the transport type: "stdio", "http", or "sse".
// If omitted, inferred from Command (stdio) or URL (http).
Type string `json:"type,omitempty"`
// Command is the executable to run for stdio servers.
Command string `json:"command,omitempty"`
// Args are command-line arguments for the executable.
Args []string `json:"args,omitempty"`
// Env contains environment variables for the server process.
// Supports variable expansion: ${VAR} and ${VAR:-default}
Env map[string]string `json:"env,omitempty"`
// URL is the endpoint for remote servers.
URL string `json:"url,omitempty"`
// Headers contains HTTP headers for authentication.
Headers map[string]string `json:"headers,omitempty"`
}
ServerConfig represents a single MCP server in Claude's format.
func (*ServerConfig) IsHTTP ¶
func (s *ServerConfig) IsHTTP() bool
IsHTTP returns true if the server uses HTTP transport.
func (*ServerConfig) IsSSE ¶
func (s *ServerConfig) IsSSE() bool
IsSSE returns true if the server uses SSE transport.
func (*ServerConfig) IsStdio ¶
func (s *ServerConfig) IsStdio() bool
IsStdio returns true if the server uses stdio transport.