Go Documentation MCP server

Access Go package documentation and project structures.
Back to servers
Setup instructions
Provider
mrjoshuak
Release date
Dec 05, 2024
Language
Go
Stats
82 stars

This MCP server provides efficient access to Go documentation, helping LLMs understand Go projects without needing to read entire source files. It significantly reduces token usage by delivering only essential documentation in a structured format.

Installation

Install the server using the Go package manager:

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

Configuration

Add the server to your Claude desktop app configuration:

{
  "mcpServers": {
    "godoc": {
      "command": "/path/to/godoc-mcp",
      "args": [],
      "env": {
        "GOPATH": "/path/to/go",
        "GOMODCACHE": "/path/to/go/pkg/mod"
      }
    }
  }
}

Usage

When connected to an MCP-capable LLM like Claude, godoc-mcp provides the get_doc tool with these parameters:

  • path: Path to the Go package or file (import path or file path)
  • target (optional): Specific symbol to document (function, type, etc.)
  • cmd_flags (optional): Additional go doc command flags
  • working_dir (optional): Working directory for module-aware documentation

Key Features

  • Documentation Retrieval: The server will:

    • Return package documentation for directories with Go files
    • List available Go packages in subdirectories for directories without Go files
    • Return standard library or third-party package documentation for import paths
  • 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 when needed
    • Sets up module context for external packages
    • Handles cleanup of temporary projects

Advanced Options

You can use these cmd_flags values for different documentation views:

  • -all: Show all documentation for package, excluding unexported symbols
  • -u: Show unexported symbols
  • -src: Show the source code instead of documentation

Example Use Cases

  • Project Understanding: "What packages does this Go project contain and what do they do?"
  • Package Interface Understanding: "What interfaces does the io package provide?"
  • Implementation Guidance: "Show me the documentation for the io.Reader interface"
  • API Usage: "Show me the documentation for the Resource type in this project"
  • Library Exploration: "Show me the documentation for the gorilla/mux Router type"
  • Method Discovery: "What methods are available on the http.Request type?"

Troubleshooting

  • Ensure local paths contain Go source files or point to directories with Go packages
  • Check that GOPATH and GOMODCACHE environment variables are set correctly in your configuration
  • For special cases, provide a specific working_dir if the automatic module context handling isn't sufficient

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "godoc" '{"command":"/path/to/godoc-mcp","args":[],"env":{"GOPATH":"/path/to/go","GOMODCACHE":"/path/to/go/pkg/mod"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "godoc": {
            "command": "/path/to/godoc-mcp",
            "args": [],
            "env": {
                "GOPATH": "/path/to/go",
                "GOMODCACHE": "/path/to/go/pkg/mod"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "godoc": {
            "command": "/path/to/godoc-mcp",
            "args": [],
            "env": {
                "GOPATH": "/path/to/go",
                "GOMODCACHE": "/path/to/go/pkg/mod"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later