Documentation
¶
Overview ¶
Package ide provides detection and configuration for IDE/agent MCP integrations.
The package centers on three interfaces:
- Adapter: identity + detection (every supported tool implements this).
- Writer: Adapter + the methods needed to merge an MCP entry into a config file. Tools whose MCP setup we automate.
- Hinter: Adapter + a one-shot Hint() string. Tools we detect but can't auto-configure (e.g. Claude Desktop where remote MCP requires OAuth via Settings -> Connectors). The CLI prints the hint instead.
Adding a new tool means dropping a file in this package, implementing either Writer or Hinter, and appending to Registry.
Index ¶
- Constants
- Variables
- func SupportedSlugs() []string
- type Adapter
- type ClaudeCode
- func (c *ClaudeCode) BuildEntry(mcpURL, apiKey string) map[string]any
- func (c *ClaudeCode) ConfigPath(scope Scope) (string, error)
- func (c *ClaudeCode) DefaultScope() Scope
- func (c *ClaudeCode) Detect() bool
- func (c *ClaudeCode) Name() string
- func (c *ClaudeCode) Slug() string
- func (c *ClaudeCode) SupportedScopes() []Scope
- func (c *ClaudeCode) TopLevelKey() string
- type ClaudeDesktop
- type Cursor
- func (c *Cursor) BuildEntry(mcpURL, apiKey string) map[string]any
- func (c *Cursor) ConfigPath(scope Scope) (string, error)
- func (c *Cursor) DefaultScope() Scope
- func (c *Cursor) Detect() bool
- func (c *Cursor) Name() string
- func (c *Cursor) Slug() string
- func (c *Cursor) SupportedScopes() []Scope
- func (c *Cursor) TopLevelKey() string
- type Gemini
- func (g *Gemini) BuildEntry(mcpURL, apiKey string) map[string]any
- func (g *Gemini) ConfigPath(scope Scope) (string, error)
- func (g *Gemini) DefaultScope() Scope
- func (g *Gemini) Detect() bool
- func (g *Gemini) Name() string
- func (g *Gemini) Slug() string
- func (g *Gemini) SupportedScopes() []Scope
- func (g *Gemini) TopLevelKey() string
- type Hinter
- type Opencode
- func (o *Opencode) BuildEntry(mcpURL, apiKey string) map[string]any
- func (o *Opencode) ConfigPath(scope Scope) (string, error)
- func (o *Opencode) DefaultScope() Scope
- func (o *Opencode) Detect() bool
- func (o *Opencode) Name() string
- func (o *Opencode) Slug() string
- func (o *Opencode) SupportedScopes() []Scope
- func (o *Opencode) TopLevelKey() string
- type Scope
- type VSCode
- func (v *VSCode) BuildEntry(mcpURL, apiKey string) map[string]any
- func (v *VSCode) ConfigPath(scope Scope) (string, error)
- func (v *VSCode) DefaultScope() Scope
- func (v *VSCode) Detect() bool
- func (v *VSCode) Name() string
- func (v *VSCode) Slug() string
- func (v *VSCode) SupportedScopes() []Scope
- func (v *VSCode) TopLevelKey() string
- type WriteResult
- type Writer
Constants ¶
const MCPServerName = "dbgorilla"
MCPServerName is the key under which dbgorilla registers its MCP server in any tool's config. Kept stable across adapters so users see the same name in every IDE.
Variables ¶
var ErrJSONCRefused = fmt.Errorf(
"target config file appears to be JSONC (has // comments); refusing to " +
"write -- run with --print-config to get the entry to paste manually",
)
ErrJSONCRefused is returned when the target config file has a .jsonc extension or contains // comments. We refuse to write rather than silently destroy the user's comments. Caller should print the entry and instruct the user to paste manually.
var Registry = []Adapter{ &ClaudeCode{}, &ClaudeDesktop{}, &Cursor{}, &VSCode{}, &Opencode{}, &Gemini{}, }
Registry holds every supported tool. Order is preserved -- shows up in help text and detection output the same way.
Functions ¶
func SupportedSlugs ¶
func SupportedSlugs() []string
SupportedSlugs returns all known slugs (writers and hinters), in Registry order, for help text.
Types ¶
type Adapter ¶
type Adapter interface {
// Name is the human-readable tool name (e.g. "Claude Code").
Name() string
// Slug is the CLI flag value (e.g. "claude-code").
Slug() string
// Detect returns true when the tool appears installed.
Detect() bool
}
Adapter is the minimal interface every supported tool implements.
func DetectInstalled ¶
func DetectInstalled() []Adapter
DetectInstalled returns adapters whose tool is present on the system.
type ClaudeCode ¶
type ClaudeCode struct{}
ClaudeCode is the Anthropic CLI agent. The preferred MCP-setup path is shelling to `claude mcp add` (handles managed-org allowlist policies); this adapter exists for the direct-write fallback when the `claude` CLI isn't on PATH.
func (*ClaudeCode) BuildEntry ¶
func (c *ClaudeCode) BuildEntry(mcpURL, apiKey string) map[string]any
func (*ClaudeCode) ConfigPath ¶
func (c *ClaudeCode) ConfigPath(scope Scope) (string, error)
ConfigPath returns the per-scope MCP config path:
- User: ~/.claude.json (or %APPDATA%\Claude\claude.json on Windows). This is Claude Code's combined settings file -- merge logic in WriteMCPConfig preserves every other top-level key.
- Project: .mcp.json in the current working directory. MCP-only file intended to be checked into source control.
func (*ClaudeCode) DefaultScope ¶
func (c *ClaudeCode) DefaultScope() Scope
func (*ClaudeCode) Detect ¶
func (c *ClaudeCode) Detect() bool
func (*ClaudeCode) Name ¶
func (c *ClaudeCode) Name() string
func (*ClaudeCode) Slug ¶
func (c *ClaudeCode) Slug() string
func (*ClaudeCode) SupportedScopes ¶
func (c *ClaudeCode) SupportedScopes() []Scope
func (*ClaudeCode) TopLevelKey ¶
func (c *ClaudeCode) TopLevelKey() string
type ClaudeDesktop ¶
type ClaudeDesktop struct{}
ClaudeDesktop is the Anthropic desktop app. It supports remote HTTP MCP only via Settings -> Connectors (UI flow, OAuth-based). The claude_desktop_config.json file ignores HTTP entries silently. Implement only Hinter, never Writer.
func (*ClaudeDesktop) Detect ¶
func (c *ClaudeDesktop) Detect() bool
func (*ClaudeDesktop) Hint ¶
func (c *ClaudeDesktop) Hint(mcpURL string) string
Hint returns the manual setup instructions. Claude Desktop's HTTP MCP requires Settings -> Connectors and a paid plan; there's no config file path that accepts a Bearer token.
func (*ClaudeDesktop) Name ¶
func (c *ClaudeDesktop) Name() string
func (*ClaudeDesktop) Slug ¶
func (c *ClaudeDesktop) Slug() string
type Cursor ¶
type Cursor struct{}
Cursor is the AI-first VS Code fork. Its MCP config is a dedicated JSON file (mcp.json), not part of the larger Cursor settings.
func (*Cursor) ConfigPath ¶
ConfigPath:
- User: ~/.cursor/mcp.json
- Project: .cursor/mcp.json (in the current working directory)
func (*Cursor) DefaultScope ¶
func (*Cursor) SupportedScopes ¶
func (*Cursor) TopLevelKey ¶
type Gemini ¶
type Gemini struct{}
Gemini is Google's gemini-cli. MCP config lives in settings.json under "mcpServers". For Streamable HTTP transport the entry uses "httpUrl" (not "url" -- that selects the deprecated SSE transport).
func (*Gemini) ConfigPath ¶
ConfigPath:
- User: ~/.gemini/settings.json
- Project: .gemini/settings.json in cwd
func (*Gemini) DefaultScope ¶
func (*Gemini) SupportedScopes ¶
func (*Gemini) TopLevelKey ¶
type Hinter ¶
Hinter is implemented by tools we detect but can't auto-configure. Hint() returns a multi-line string with manual setup instructions.
type Opencode ¶
type Opencode struct{}
Opencode is sst/opencode -- TUI agent. MCP config lives inside the shared opencode.json under the "mcp" key; entries take type:"remote" for HTTP servers.
func (*Opencode) ConfigPath ¶
ConfigPath:
- User: ~/.config/opencode/opencode.json
- Project: opencode.json in cwd
Note: opencode also accepts opencode.jsonc with comments. We deliberately target the .json variant for writes and let the JSONC-refusal logic in WriteMCPConfig redirect users to --print-config if they're using JSONC.
func (*Opencode) DefaultScope ¶
func (*Opencode) SupportedScopes ¶
func (*Opencode) TopLevelKey ¶
type VSCode ¶
type VSCode struct{}
VSCode targets the official MCP support shipped in mid-2025. Its config file uses the top-level key "servers" -- NOT "mcpServers". This is the most common copy-paste mistake when wiring up MCP across IDEs.
func (*VSCode) ConfigPath ¶
ConfigPath:
- Project: .vscode/mcp.json (in cwd)
- User: OS-specific Code/User/mcp.json
func (*VSCode) DefaultScope ¶
DefaultScope: project. VS Code's MCP UX is built around .vscode/mcp.json living next to the workspace -- that's the conventional place. Users who want global setup pass --scope user explicitly.
func (*VSCode) SupportedScopes ¶
func (*VSCode) TopLevelKey ¶
TopLevelKey is "servers", not "mcpServers". This is the load-bearing difference between VS Code and every other IDE in this package.
type WriteResult ¶
type WriteResult struct {
Path string
BackupPath string // empty if no backup needed (fresh file or no-op)
Created bool // true if the config file did not exist before
Updated bool // true if an existing dbgorilla entry was replaced
NoOp bool // true if the existing entry already matched
}
WriteResult describes what WriteMCPConfig did. Useful for the caller to print accurate user-facing messages ("wrote", "updated", "no change").
func WriteMCPConfig ¶
func WriteMCPConfig(w Writer, mcpURL, apiKey string, scope Scope) (WriteResult, error)
WriteMCPConfig merges the dbgorilla MCP entry into the tool's config file at the requested scope. Safety contract:
- Always reads existing config first; never starts from a blank slate.
- Backs up to <path>.backup.<timestamp> (mode 0600) before any write.
- Preserves every other top-level key in the file.
- Preserves every other entry under the MCP top-level key.
- Refuses to write JSONC files (would destroy comments) -- caller should fall back to --print-config.
- Idempotent: no write when the existing entry already matches.
Returns the result struct for accurate user messaging.
type Writer ¶
type Writer interface {
Adapter
// SupportedScopes returns which scopes this tool's config supports.
// Most tools support {ScopeUser, ScopeProject}; some only support one.
SupportedScopes() []Scope
// DefaultScope returns the scope to use when the user passes no flag.
DefaultScope() Scope
// ConfigPath returns the absolute path to the MCP config file for the
// requested scope. Project-scoped paths are resolved against the
// current working directory.
ConfigPath(scope Scope) (string, error)
// TopLevelKey is the JSON key under which MCP servers live in this
// tool's config (e.g. "mcpServers" for Claude/Cursor/Gemini, "servers"
// for VS Code, "mcp" for opencode).
TopLevelKey() string
// BuildEntry returns the per-tool MCP server entry shape for the
// dbgorilla server. Different tools have different field names
// (e.g. Gemini wants "httpUrl", others want "url").
BuildEntry(mcpURL, apiKey string) map[string]any
}
Writer is implemented by tools whose MCP config we can write.