go_mcp_tools

package module
v0.0.0-...-2cb4166 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2025 License: MIT Imports: 18 Imported by: 0

README

Go MCP Tools

Collection of tools that I feel are missing when using Copilot agent mode in Go projects.

No tools require the column index for symbols like the gopls cli, as the coding agent does not have easy access to this information and is terrible at counting. Instead it can pass the symbol name and we look up the column index instead where needed.

The tools may be served via stdio or http. The mark3labs MCP server implementation is used for the server.

Tools

Inspect

Look at a package, file, or symbol and get a summary. The summary leverages gopls and go/ast for adding useful information such as references, implementers, scopes, call hierarchies e.t.c.

Rename

Rename a symbol. Basically just calls gopls rename.

Usage

May be compiled or run directly using go, its entrypoint being cmd/main.go.

VSCode

In your settings json file, add the following:

    "mcp": {
        "servers": {
            "go": {
                "type": "stdio",
                "command": "/bin/bash",
                "args": [
                    "-c",
                    "go run /path/to/go-mcp-tools/cmd/main.go server",
                ]
            },
        }
    },

You can use Ctrl+Shift+P or Cmd+Shift+P to select MCP: List Servers, select the go server and start it.

Now the tools should show up when you configure available tools for your coding agent.

Other Editors/Coding Applications

Look up how to integrate MCP tools with the application you are using and use either stdio or http transport.

Disclaimers

80% of this project is written by Claude, with heavy supervision.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddInspectTool

func AddInspectTool(mcpServer *server.MCPServer)

func AddRenameTool

func AddRenameTool(mcpServer *server.MCPServer)

func Inspect

func Inspect(
	path string,
	lineNumber int,
	symbolName string,
	includePrivate bool,
	workspaceDir string,
) (string, error)

Inspect analyzes a Go symbol (package, file, function, type, etc.) path can be a directory path, file path, or import statement path lineNumber and symbolName are optional for file paths to specify a particular symbol includePrivate determines whether private symbols are included workspaceDir is the working directory for package resolution and reference finding, and is required.

func NewMCPServer

func NewMCPServer(config *ServerConfig) *server.MCPServer

NewMCPServer creates a new MCP server with the specified configuration

func Rename

func Rename(
	filePath string,
	lineNumber int,
	symbolName string,
	newName string,
) (string, error)

func ServeHTTP

func ServeHTTP(mcpServer *server.MCPServer, host string, port string) error

ServeHTTP starts the MCP server on HTTP transport at the specified address

func ServeStdio

func ServeStdio(mcpServer *server.MCPServer) error

ServeStdio starts the MCP server on stdio transport

Types

type ServerConfig

type ServerConfig struct {
	Name    string
	Version string
}

ServerConfig holds configuration for the MCP server

func DefaultServerConfig

func DefaultServerConfig() *ServerConfig

DefaultServerConfig returns a default server configuration

type Transport

type Transport string

Transport defines the server transport method

const (
	StdioTransport Transport = "stdio"
	HTTPTransport  Transport = "http"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL