Skip to content
Back to search

godoc-mcp

MCP server that reduces LLM context usage when AI coding agents work with Go — structured documentation instead of source-file dumps.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/mrjoshuak--godoc-mcp/badge.svg)](/listings/mrjoshuak--godoc-mcp)

HTML

<a href="/listings/mrjoshuak--godoc-mcp"><img src="/api/listings/mrjoshuak--godoc-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

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

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 226 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # godoc-mcp
  2. [![Go Report Card](https://goreportcard.com/badge/github.com/mrjoshuak/godoc-mcp)](https://goreportcard.com/report/github.com/mrjoshuak/godoc-mcp)
  3. [![Go Reference](https://pkg.go.dev/badge/github.com/mrjoshuak/godoc-mcp.svg)](https://pkg.go.dev/github.com/mrjoshuak/godoc-mcp)
  4. [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
  5. ## Overview
  6. `godoc-mcp` is a Model Context Protocol (MCP) server that provides efficient access to Go documentation. It helps LLMs understand Go projects by providing direct access to package documentation without needing to read entire source files. `godoc-mcp` can vastly improve the performance of using LLMs to develop in Go by substantially reducing the number of tokens needed to understand and make use of Go packages.
  7. ## Getting Started
  8. ```bash
  9. go install github.com/mrjoshuak/godoc-mcp@latest
  10. ```
  11. ## Why Use godoc-mcp?
  12. In a sentence: **`godoc-mcp` provides a more token efficient way for LLMs to understand Go projects.**
  13. Traditional file-reading approaches require LLMs to process entire source files often many files to understand a single package. `godoc-mcp` provides several advantages:
  14. 1. **Token Efficiency**: Returns only the essential documentation, reducing token usage significantly
  15. 2. **Structured Information**: Provides official package documentation in a consistent, well-structured format
  16. 3. **Project Navigation**: Smart handling of project structures helps LLMs understand multi-package projects
  17. 4. **Integration Ready**: Works alongside other MCP servers, enabling both high-level and detailed code analysis
  18. 5. **Performance**: Caching and optimized token usage make `godoc-mcp` a fast and efficient tool for Go development
  19. 6. **Local**: Does not require an internet connection to access documentation
  20. With `godoc-mcp`, a LLM can get precisely the information it needs without having to read entire source files. Here are the different levels of detail that an LLM can get.
  21. - Documentation for one exported symbol
  22. - The complete source for one symbol
  23. - A list of all exported symbols (the concise documentation)
  24. - A list of all symbols including unexported symbols
  25. - The full documentation for a package
  26. - The entire source for a package
  27. This makes `godoc-mcp` an essential tool for Go developers using LLMs by enabling LLMs to understand significantly more, and in more detail, about the context than previously possible in any programming language.
  28. ## Features
  29. The server will:
  30. 1. For directories with Go files: Return package documentation
  31. 2. For directories without Go files: List available Go packages in subdirectories
  32. 3. For import paths: Return standard library or third-party package documentation
  33. - **Efficient Documentation Access**: Retrieves official Go documentation with minimal token usage
  34. - **Smart Package Discovery**: When pointed at a directory without Go files, lists available Go packages in subdirectories
  35. - **Flexible Path Support**:
  36. - Local file paths (e.g., "/full/path/to/mypackage")
  37. - Import paths (e.g., "io", "github.com/user/repo")
  38. - **Automatic Module Context**:
  39. - Creates temporary Go projects when needed
  40. - Automatically sets up module context for external packages
  41. - No manual module setup required for any package documentation
  42. - Handles cleanup of temporary projects
  43. - **Module-Aware**: Supports documentation for third-party packages through working directory context (i.e. it will run `go doc` from the working directory)
  44. - **Performance Optimized**:
  45. - Built-in response caching
  46. - Efficient token usage through focused documentation retrieval
  47. - Metadata about response sizes
  48. - Smart handling of standard library vs external packages
  49. ### Examples
  50. In addition to providing documentation while working on coding tasks. `godoc-mcp` can also be used to explore Go projects and packages. Here are some examples for general prompting:
  51. #### Project Understanding
  52. "I'm looking at a Go project at /path/to/some/project. What packages does it contain and what do they do?"
  53. #### Package Interface Understanding
  54. "What interfaces does the io package provide? I'm particularly interested in anything related to reading."
  55. #### Implementation Guidance
  56. "I need to implement the io.Reader interface. Show me its documentation and any related types I should know about."
  57. #### API Usage
  58. "Show me the documentation for the Resource type in the /path/to/some/project. I need to understand how to create and use it."
  59. #### Library Exploration
  60. "I'm in /path/to/some/project which uses github.com/gorilla/mux. Show me the documentation for the Router type."
  61. #### Method Discovery
  62. "What methods are available on the http.Request type? I'm working with standard library HTTP handlers."
  63. #### Focused Learning
  64. "Explain how to configure the Server type in the /path/to/project/server package."
  65. #### Package Browsing
  66. "I'm in a new Go project directory and see multiple packages. Can you show me what each one does?"
  67. ## Usage
  68. ### Transport Options
  69. godoc-mcp supports three transport modes:
  70. - **stdio** (default): Standard input/output, for local MCP clients like Claude Desktop
  71. - **sse**: Server-Sent Events over HTTP, for web-based MCP clients
  72. - **http**: Streamable HTTP, the MCP specification's recommended HTTP transport
  73. ```bash
  74. # Default stdio mode
  75. godoc-mcp
  76. # SSE mode on port 8080
  77. godoc-mcp --transport sse --addr :8080
  78. # Streamable HTTP mode
  79. godoc-mcp --transport http --addr :9090
  80. ```
  81. ### Docker
  82. ```bash
  83. docker pull ghcr.io/mrjoshuak/godoc-mcp:latest
  84. ```
  85. For use with [Docker MCP Gateway](https://docs.docker.com/ai/mcp-catalog-and-toolkit/mcp-gateway/), add to your MCP configuration:
  86. ```json
  87. {
  88. "mcpServers": {
  89. "godoc": {
  90. "command": "docker",
  91. "args": ["run", "-i", "--rm", "ghcr.io/mrjoshuak/godoc-mcp:latest"]
  92. }
  93. }
  94. }
  95. ```
  96. To access local project documentation, mount your project directory and use `/workspace` as the `working_dir` parameter:
  97. ```json
  98. {
  99. "mcpServers": {
  100. "godoc": {
  101. "command": "docker",
  102. "args": ["run", "-i", "--rm", "-v", "/path/to/project:/workspace", "ghcr.io/mrjoshuak/godoc-mcp:latest"]
  103. }
  104. }
  105. }
  106. ```
  107. To run with SSE transport via Docker:
  108. ```bash
  109. docker run --rm -p 8080:8080 ghcr.io/mrjoshuak/godoc-mcp:latest --transport sse --addr :8080
  110. ```
  111. ### Claude Code
  112. ```bash
  113. claude mcp add godoc-mcp -- godoc-mcp
  114. ```
  115. ### Claude Desktop
  116. To add to the Claude desktop app, edit your MCP config:
  117. ```json
  118. {
  119. "mcpServers": {
  120. "godoc": {
  121. "command": "godoc-mcp"
  122. }
  123. }
  124. }
  125. ```
  126. If `go doc` can't find your Go installation, add environment variables:
  127. ```json
  128. {
  129. "mcpServers": {
  130. "godoc": {
  131. "command": "godoc-mcp",
  132. "env": {
  133. "GOPATH": "/path/to/go",
  134. "GOMODCACHE": "/path/to/go/pkg/mod"
  135. }
  136. }
  137. }
  138. }
  139. ```
  140. ### Tools
  141. godoc-mcp provides two tools:
  142. #### `get_doc`
  143. Get documentation for a Go package, type, function, or method.
  144. - `path` (required): Package import path (e.g., `io`, `github.com/user/repo`) or local file path
  145. - `target` (optional): Specific symbol to document (function, type, etc.)
  146. - `cmd_flags` (optional): Additional go doc flags (allowed: `-all`, `-src`, `-u`, `-short`, `-c`)
  147. - `working_dir` (optional): Working directory for module context (required for relative paths)
  148. - `page` (optional): Page number for paginated results (default: 1)
  149. - `page_size` (optional): Lines per page, 100-5000 (default: 1000)
  150. #### `list_packages`
  151. List all sub-packages under a Go package path. Use this to discover the correct import paths for sub-packages instead of guessing.
  152. - `path` (required): Root package import path (e.g., `net`, `github.com/user/repo`)
  153. - `working_dir` (optional): Working directory for module context (required for relative paths)
  154. ## Troubleshooting
  155. - For local paths, ensure they contain Go source files or point to directories containing Go packages
  156. - If you see module-related errors, ensure GOPATH and GOMODCACHE environment variables are set correctly in your MCP server configuration
  157. - The server automatically handles module context for external packages, but you can still provide a specific working_dir if needed for special cases
  158. ## License
  159. This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.