Skip to content

danicat/godoctor

Repository files navigation

GoDoctor

GoDoctor is a Model Context Protocol (MCP) server and CLI extension for Go development. It provides structured tools to help coding agents navigate, edit, build, and test Go codebases safely.

User Instructions

Installation

Antigravity CLI

GoDoctor ships as a Gemini CLI-compatible extension. Install using the gemini command (included with Antigravity CLI), then import into agy:

# Step 1: install the extension (downloads the pre-compiled binary from the GitHub release)
gemini extensions install https://github.com/danicat/godoctor

# Step 2: import into Antigravity CLI
agy plugin import gemini

After import, GoDoctor is active in all future agy sessions. Skills, hooks, and the MCP server are all registered automatically.

Gemini CLI (standalone)

gemini extensions install https://github.com/danicat/godoctor

Claude Code

  1. Install the binary globally:
    go install github.com/danicat/godoctor/cmd/godoctor@latest
  2. Register the MCP server:
    claude mcp add --transport stdio --scope user godoctor -- godoctor
  3. Append agent instructions to your project:
    godoctor --agents >> CLAUDE.md

Usage Instructions

Once installed, GoDoctor runs automatically in the background of your agent-compatible client. The client agent will discover and call the exposed tools during Go programming tasks.

To manually print system instructions for an LLM agent:

godoctor --agents

To see the list of active tools:

godoctor --list-tools

Specific Documentation

Command Interception (Hooks)

When running inside the Antigravity or Gemini CLI, GoDoctor intercepts standard terminal commands (such as go build, cat, or sed) and raw file tools when they operate on Go source files (.go). It redirects the agent to GoDoctor's specialized tools (smart_build, smart_read, and smart_edit). Non-Go files (Python, TypeScript, Markdown, etc.) are unaffected and pass through normally. This prevents syntax errors and conserves context window tokens.

Configuration (Command-line Flags)

Flag Description Default
--allow Comma-separated whitelist of tools to enable. ""
--disable Comma-separated list of tools to disable. ""
--listen Address for HTTP transport (defaults to standard input/output). ""
--list-tools Prints all registered tools and exits. false
--agents Prints system instructions for LLM agents and exits. false
--version Prints the version and exits. false

Features and Tools

GoDoctor provides tools divided into four functional areas:

Code Navigation
  • list_files lists files in the workspace while avoiding version control directories.
  • smart_read reads files, extracts code outlines, and appends definitions of referenced types. Powered by a high-performance persistent background gopls daemon over a stateful JSON-RPC session, delivering type-tags in milliseconds.
  • describe_symbol provides semantic detail for any symbol, including declaration signatures, comments, and references, querying the shared background gopls process instantly.
Code Editing
  • smart_edit handles atomic modifications across multiple files. It formats the code and automatically rolls back changes if the compiler detects a syntax error.
Go Toolchain Integration
  • smart_build manages module tidying, code modernization, formatting, compiling, testing, and linting.
  • add_dependency installs Go modules and pulls their documentation.
  • read_docs fetches API documentation for packages and symbols.
Testing
  • mutation_test runs Selene mutation tests to check test coverage quality.
  • test_query queries test results and coverage data using SQL.

Developer Instructions

Building

Build the project from source using the Makefile:

git clone https://github.com/danicat/godoctor.git
cd godoctor
make build

This compiles the server binary to bin/godoctor.

To install the binary globally to your $GOPATH/bin:

make install

Testing

Run the test suite:

make test

To run tests and generate a coverage report:

make test-cov

Running Locally

Run the compiled binary directly to test behavior:

./bin/godoctor

Check active tools:

./bin/godoctor --list-tools

Releasing

GoDoctor relies on Git tags for versioning. Build versions are dynamically injected at compile time using git describe.

To release a new version:

  1. Update the version string in gemini-extension.json:

    make bump-version VERSION=0.16.2
  2. Commit the manifest changes:

    git add gemini-extension.json
    git commit -m "chore: bump version to 0.16.2"
  3. Create and push a new Git tag:

    git tag v0.16.2
    git push origin v0.16.2

The release pipeline will automatically run GoReleaser when a new tag is pushed.

To test the GoReleaser configuration locally, generate a snapshot release:

make snapshot

License

Apache 2.0

About

A Model Context Protocol server for Go developers

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors