| name | cercano-document |
| description | Generate doc comments for exported Go symbols using local AI and write them directly to the file. The host never sees the file contents — Cercano handles the entire read-think-write cycle locally. |
| TRIGGER when | user asks to add doc comments, godoc, or documentation to Go source files. |
| DO NOT TRIGGER when | user asks to write README/markdown documentation or document non-Go code (do that directly instead). |
| compatibility | Requires Cercano server running and connected to an Ollama instance. Currently supports Go source files only. |
Cercano Document
Generate doc comments for exported Go symbols using local AI and write them directly to the source file.
MCP Tool
Tool name: cercano_document
Parameters
| Parameter | Type | Required | Description |
|---|
| file_path | string | Yes | Path to the Go source file to document. |
| style | string | No | Doc comment style: "minimal" (1-2 sentences, default) or "detailed" (multi-line with params). |
| dry_run | bool | No | If true, report what would be documented without writing changes. |
| project_dir | string | No | Project root directory for context-aware responses. |
How It Works
- Parses the Go file using the standard go/ast package
- Identifies exported symbols (functions, methods, types, interfaces, constants) without doc comments
- Generates a doc comment for each using local inference (one symbol at a time)
- Inserts comments at the correct positions and formats with gofmt
- Returns a summary of what was documented
The host agent never sees the file contents — only the summary.
Safety
- Creates a backup in
.cercano/backups/ before writing
- Validates the result with
go/format
- Restores from backup if validation fails
- Skips symbols where the model returns garbage
Examples
Document a file:
{"file_path": "internal/engine/ollama.go"}
Preview without writing:
{"file_path": "internal/engine/ollama.go", "dry_run": true}
Detailed style:
{"file_path": "internal/engine/ollama.go", "style": "detailed"}