Purpose
godoc-mcp is a tool for AI coding agents that provides a more token-efficient way to access documentation during Go language development. The traditional file-reading approach requires a large language model (LLM) to process entire source files, and sometimes many files must be read to understand a single package; godoc-mcp instead returns only the necessary documentation content.
Main Capabilities
- Token Efficiency: Returns only the core documentation, significantly reducing token consumption.
- Structured Information: Provides official package documentation in a consistent, standardized structure.
- Project Navigation: Intelligently handles project structure, helping the LLM understand multi-package projects.
- Integration-Ready: Can work together with other MCP servers, balancing high-level and fine-grained code analysis.
- Performance: Built-in caching and optimized token usage.
- Localization: Accessing documentation requires no internet connection.
The LLM can obtain information at different levels of detail, including: documentation for a single exported symbol, the complete source code of a single symbol, a list of all exported symbols (condensed documentation), a complete symbol list including unexported symbols, the complete documentation of a package, and the complete source code of a package.
Server behavior:
- Directory containing Go files: returns package documentation.
- Directory not containing Go files: lists the Go packages available in subdirectories.
- Import path: returns documentation for a standard library or third-party package.
Usage
Flexible path support:
- Local file paths (e.g. "/full/path/to/mypackage")
- Import paths (e.g. "io", "github.com/user/repo")
Automatic module context: Creates temporary Go projects as needed; automatically sets up module context for external packages; no manual module configuration is required for documentation of any package; automatically cleans up temporary projects.
Module awareness: Supports third-party package documentation through working directory context (i.e. running go doc from the working directory).
Performance optimization: Built-in response caching; efficient token usage through focused documentation retrieval; provides response size metadata; intelligently distinguishes between standard library and external packages.
Transport modes:
- stdio (default): standard input/output, for local MCP clients such as Claude Desktop.
- sse: HTTP-based Server-Sent Events, for web-based MCP clients.
- http: Streamable HTTP, the HTTP transport method recommended by the MCP specification.
Docker MCP Gateway configuration example (add to the MCP configuration):
{
"mcpServers": {
"godoc-mcp": {
"command": "docker",
"args": ["run", "-i", "--rm", "mrjoshuak/godoc-mcp"]
}
}
}
When accessing local project documentation, mount the project directory and use /workspace as the working_dir parameter.
Docker run example for the SSE transport method:
docker run -p 8080:8080 mrjoshuak/godoc-mcp --transport sse --addr :8080
When adding to the Claude desktop app, edit the MCP configuration.
If go doc cannot find the Go installation, add the environment variables: GOPATH and GOMODCACHE.
Two tools provided:
-
Get documentation for a Go package, type, function, or method.
- path (required): package import path (such as io, github.com/user/repo) or local file path.
- target (optional): the specific symbol (function, type, etc.) to generate documentation for.
- cmd_flags (optional): additional go doc flags (allowed: -all, -src, -u, -short, -c).
- working_dir (optional): working directory for module context (required for relative paths).
- page (optional): page number for pagination (default 1).
- page_size (optional): number of lines per page, 100–5000 (default 1000).
-
List all subpackages under a Go package path. Used to discover the correct import paths of subpackages rather than guessing.
- path (required): root package import path (such as net, github.com/user/repo).
When to use
In addition to providing documentation during coding tasks, godoc-mcp can also be used to explore Go projects and packages. Example prompts:
- "I am looking at a Go project at /path/to/some/project. What packages does it contain, and what does each do?"
- "What interfaces does the io package provide? I am especially interested in content related to reading."
- "I need to implement the io.Reader interface. Show me its documentation and the related types I should know about."
- "Show me the documentation for the Resource type in /path/to/some/project. I need to understand how to create and use it."
- "I am at /path/to/some/project, and it uses github.com/gorilla/mux. Show me the documentation for the Router type."
- "What methods does the http.Request type have? I am using the standard library HTTP handler."
- "Explain how to configure the Server type in the /path/to/project/server package."
- "I am in a new Go project directory, and I see multiple packages. Can you explain what each of them does?"
Limitations
- Local paths must contain Go source files, or point to a directory containing Go packages.
- If module-related errors occur, make sure the GOPATH and GOMODCACHE environment variables in the MCP server configuration are set correctly.
- The server automatically handles module context for external packages; in special cases, a specific working_dir can still be provided.
This project is licensed under the MIT License; see the LICENSE file for details.