Register the server with an editor¶
You have a Cobra CLI that mounts cli.Command, and you want Claude Desktop,
Cursor or VS Code to launch it as an MCP server. The editor helpers write the
entry for you and leave the rest of the editor's configuration alone.
Register¶
Run the helper for the editor, from the binary the editor should launch:
Each writes an entry named after the root command into the editor's file:
| Editor | File |
|---|---|
| Claude Desktop | claude_desktop_config.json under the platform's application configuration directory (~/Library/Application Support/Claude on macOS, %APPDATA%\Claude on Windows, $XDG_CONFIG_HOME/Claude or ~/.config/Claude on Linux), key mcpServers |
| Cursor | ~/.cursor/mcp.json, key mcpServers |
| VS Code | the user mcp.json under Code/User in the same configuration directory, key servers |
The entry points at this binary's absolute path with the arguments mcp start
(or the mcp command's real path when a tool nests it). Cursor and VS Code
entries carry "type": "stdio"; Claude Desktop's do not.
Register for one project only¶
Cursor and VS Code read a workspace file as well. Run from the project directory:
my-tool mcp cursor enable --workspace # .cursor/mcp.json
my-tool mcp vscode enable --workspace # .vscode/mcp.json
Name the entry, pass environment, start verbose¶
my-tool mcp vscode enable --server-name my-tool-dev --env API_BASE=https://staging.example --log-level debug
--env KEY=value is repeatable and lands in the entry's env. --log-level
is appended to the entry's arguments, so the server starts at that level.
--config-path <file> names a file elsewhere.
Remove or inspect¶
disable removes this entry only and is not an error when it is absent.
list prints the file's path and each entry's command line.
What the helpers promise¶
- Other entries in the file are preserved; running
enableagain replaces this entry and nothing else. - Writes are atomic (a temporary file renamed into place), so a crash cannot leave a half-written file.
- A file that is not a JSON object, or whose servers key is not an object, is refused untouched with a message asking you to fix it by hand. The helpers never repair or reformat a file they cannot parse.
- The file is re-indented on write. That is the one cosmetic change a run makes.
The command tree reference lists every flag.