Gopls MCP server

Bridges the Go Programming Language Server (gopls) with AI systems, enabling advanced code analysis, navigation, completion, and diagnostic capabilities for Go projects.
Back to servers
Provider
Hubert Loiseaufcms
Release date
Apr 08, 2025
Language
Go
Stats
24 stars

This MCP LSP Go server enables AI assistants like Claude to interact with Go's Language Server Protocol, providing advanced code analysis features such as navigation to definitions, finding references, checking diagnostics, and getting completion suggestions.

Installation

To install the MCP LSP Go server, run the following command:

go install github.com/hloiseaufcms/mcp-gopls/cmd/mcp-gopls@latest

Make sure you have Go 1.21 or higher installed, along with gopls:

go install golang.org/x/tools/gopls@latest

Configuration

Adding to Cursor

To add the MCP server to Cursor, add the following configuration:

{
  "mcpServers": {
    "mcp-gopls": {
      "command": "mcp-gopls"
    }
  }
} 

Available Tools

The MCP server provides several powerful tools for working with Go code:

Tool Description
go_to_definition Navigate to the definition of a symbol
find_references Find all references to a symbol
check_diagnostics Get diagnostics for a file
get_hover_info Get detailed information about a symbol
get_completion Get completion suggestions at a position
analyze_coverage Analyze test coverage for Go code

Usage Examples

You can use the MCP server with AI assistants that support the Model Context Protocol. Here are some example queries you can make:

# Finding definitions
Can you find the definition of the `ServeStdio` function in this project?

# Checking for errors
Are there any errors in my main.go file?

# Getting information about symbols
What does the Context.WithTimeout function do in Go?

The AI assistant will use the MCP server to analyze your Go code and provide accurate responses based on the codebase context.

Integration with Other Tools

This MCP server can be used with any tool that supports the MCP protocol. For example, with Ollama:

  1. Make sure Ollama is running
  2. The MCP server runs independently and communicates through stdin/stdout
  3. Configure your client to use the MCP server as a tool provider

How to add this MCP server to 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 > MCP and click "Add new global MCP server".

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

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

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