home / mcp / godoc mcp server

Godoc MCP Server

go doc mcp server

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "mrjoshuak-godoc-mcp": {
      "command": "/path/to/godoc-mcp",
      "args": [],
      "env": {
        "GOPATH": "YOUR_GOPATH",
        "GOMODCACHE": "YOUR_GOMODCACHE"
      }
    }
  }
}

godoc-mcp is an MCP server that delivers token-efficient access to Go package documentation, helping you empower LLMs to understand Go projects without scanning entire source trees. It provides structured documentation for packages and symbols, supports module context automatically, and can cache responses for faster repeated queries.

How to use

Connect to godoc-mcp from your MCP client to request package documentation. You will typically use the get_doc tool to specify a path (either a local package path or an import path), an optional target symbol, and any extra flags to tailor the output. The server prioritizes returning official package documentation in a concise, structured form, and can also reveal complete symbol details or full package docs when needed.

Common usage patterns include: getting documentation for a single exported symbol, listing all exported symbols with concise documentation, or drilling into a package’s full documentation. You can point the server at a local directory with Go packages or an import path for standard library or third-party packages. When external packages are requested, the server automatically creates a temporary module context to retrieve accurate documentation.

How to install

Prerequisites: you need a Go toolchain installed on the host where you run the MCP server.

Install the godoc-mcp server and prepare to run it as a local (stdio) MCP server.

go install github.com/mrjoshuak/godoc-mcp@latest

# Optional: set up environment if your project relies on specific GOPATH/module cache locations
export GOPATH=/path/to/go
export GOMODCACHE=/path/to/go/pkg/mod

# Start the MCP server (stdio/local)
/path/to/godoc-mcp

Additional tips and notes

The server is designed to run as a local MCP server. It’s capable of using either local Go package paths or import paths and will manage module context automatically for external packages. You can adjust behavior with optional flags and environment variables to suit your environment and project layout.

Troubleshooting

For local paths, ensure they contain Go source files or point to directories containing Go packages. If module-related errors occur, verify GOPATH and GOMODCACHE environment variables are set correctly in your MCP configuration. The server handles module context for external packages automatically, but you can provide a specific working_dir if you have special cases.

Available tools

get_doc

Tool exposed by godoc-mcp to fetch documentation for a path, with optional symbol targeting and flags to control output (e.g., -all, -u, -src).