Go Documentation
Integrates with
Go
go-mcp
This project is a Model Context Protocol (MCP) server designed to provide Go documentation tools for AI assistants. It exposes Go's documentation and package listing capabilities through MCP, allowing AI systems to access official Go documentation and understand Go codebases more effectively.
Features
- Go Documentation Access: Query documentation for Go packages, types, functions, or methods using the
go doc
command. - Package Listing: List available packages in a Go module using the
go list
command.
Requirements
- Go 1.16 or later
- A working Go environment with GOPATH configured
- Access to the packages you want to document
Setup
-
Install the package:
go install github.com/wricardo/go-mcp@latest
-
Configure your MCP-compatible assistant by adding the following to your MCP settings:
"go-mcp": { "command": "go-mcp", "env": { "WORKDIR": "/path/to/your/go/project" }, "disabled": false, "autoApprove": [] }
Tools
-
go_doc: Get Go documentation for packages, types, functions, or methods.
- Parameters:
pkgSymMethodOrField
: The package, symbol, method, or field to look up documentation for.cmd_flags
: (Optional) Additional command flags like-all
,-src
, or-u
.
- Parameters:
-
go_list: List Go packages or modules.
- Parameters:
packages
: Array of package patterns to list (e.g.,["./...", "github.com/user/repo/..."]
).cmd_flags
: (Optional) Additional command flags like-json
.
- Parameters:
Examples
Using go_doc
{
"pkgSymMethodOrField": "net/http",
"cmd_flags": ["-all"]
}
{
"pkgSymMethodOrField": "fmt.Println",
"cmd_flags": ["-src"]
}
Using go_list
{
"packages": ["./..."]
}
{
"packages": ["github.com/user/repo/module..."]
}
{
"packages": ["github.com/user/repo/..."]
}
Best Practices
- Always try
go_doc
first before examining source code directly - Start with basic package documentation before looking at specific symbols
- Use the
-all
flag for comprehensive package documentation - Use the
-u
flag to see unexported symbols - Use the
-src
flag to see source code when documentation is insufficient