mcp-gopls

mcp-gopls

MCP server bridging Go's LSP and AI assistants for advanced code analysis.

48
Stars
5
Forks
48
Watchers
1
Issues
Implements a Model Context Protocol (MCP) server enabling AI assistants to interact with the Go Language Server Protocol (LSP) for analyzing and understanding Go code. Provides tools for navigation, diagnostics, references, hover info, completion suggestions, and code coverage. Integrates with 'gopls' to deliver precise code intelligence tailored for AI-driven workflows. Designed for seamless integration with platforms that support MCP, including AI development assistants.

Key Features

Integration with Go's Language Server Protocol (gopls)
Code navigation via 'go_to_definition' and 'find_references' tools
Diagnostics checking for errors and warnings
Hover information and detailed symbol documentation
Code completion suggestions at specific positions
Test coverage analysis
Seamless operation as an MCP server
Extensible design for compatibility with MCP-capable clients
Usage through stdin/stdout for independent operation
Can be deployed alongside tools like Ollama and Cursor

Use Cases

Powering AI assistants with Go language code intelligence
Navigating and exploring large Go codebases programmatically
Automated code quality checks through diagnostics retrieval
Providing in-context symbol documentation for language models
Assisting completion engines with intelligent suggestions in Go
Analyzing and reporting on Go test coverage for model-driven development
Facilitating educational tools with in-depth Go code querying
Supporting collaborative coding platforms with AI-powered code insights
Enhancing developer productivity with AI-driven code navigation
Automating cross-referencing and symbol lookups in Go projects

README

MCP LSP Go

A Model Context Protocol (MCP) server that allows AI assistants like Claude to interact with Go's Language Server Protocol (LSP) and benefit from advanced Go code analysis features.

Overview

This MCP server helps AI assistants to:

  • Use LSP to analyze Go code
  • Navigate to definitions and find references
  • Check code diagnostics
  • Get hover information for symbols
  • Get completion suggestions

Architecture

This project uses the mark3labs/mcp-go library to implement the Model Context Protocol. The MCP integration enables seamless communication between AI assistants and Go tools.

The server communicates with gopls, the official language server for Go, via the Language Server Protocol (LSP).

Features

  • LSP Integration: Connection to Go's Language Server Protocol for code analysis
  • Code Navigation: Finding definitions and references in the code
  • Code Quality: Getting diagnostics and errors
  • Advanced Information: Hover information and completion suggestions

Project Structure

bash
.
├── cmd
│   └── mcp-gopls        # Application entry point
├── pkg
│   ├── lsp             # LSP client to communicate with gopls
│   │   ├── client      # LSP client implementation
│   │   └── protocol    # LSP protocol types and features
│   ├── server          # MCP server
│   └── tools           # MCP tools exposing LSP features

Installation

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

Add to Cursor

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

MCP Tools

The MCP server provides the following tools:

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 Example

Using the server with AI assistants that support MCP:

Markdown
# Ask the AI to get information about the code
Can you find the definition of the `ServeStdio` function in this project?

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

# Ask for information about a symbol
What does the Context.WithTimeout function do in Go?

Development

bash
git clone https://github.com/hloiseaufcms/mcp-gopls.git
cd mcp-gopls
go mod tidy
go build -o mcp-gopls cmd/mcp-gopls/main.go
./mcp-gopls

Prerequisites

  • Go 1.21 or higher
  • gopls installed (go install golang.org/x/tools/gopls@latest)

Integration with Ollama

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

  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

License

Apache License 2.0

Star History

Star History Chart

Repository Owner

Repository Details

Language Go
Default Branch main
Size 3,312 KB
Contributors 2
License Apache License 2.0
MCP Verified Nov 12, 2025

Programming Languages

Go
99.15%
Makefile
0.85%

Tags

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • MCP Language Server

    MCP Language Server

    Bridge codebase navigation tools to AI models using MCP-enabled language servers.

    MCP Language Server implements the Model Context Protocol, allowing MCP-enabled clients, such as LLMs, to interact with language servers for codebase navigation. It exposes standard language server features—like go to definition, references, rename, and diagnostics—over MCP for seamless integration with AI tooling. The server supports multiple languages by serving as a proxy to underlying language servers, including gopls, rust-analyzer, and pyright.

    • 1,256
    • MCP
    • isaacphi/mcp-language-server
  • godoc-mcp

    godoc-mcp

    Token-efficient Go documentation server for LLMs using Model Context Protocol.

    godoc-mcp is a Model Context Protocol (MCP) server that provides efficient, structured access to Go package documentation for large language models. It enables LLMs to understand Go projects without reading entire source files by supplying essential documentation and source code at varying levels of granularity. The tool supports project navigation, automatic module setup, caching, and works offline for both standard and third-party Go packages.

    • 88
    • MCP
    • mrjoshuak/godoc-mcp
  • godoc-mcp-server

    godoc-mcp-server

    Provides Go package documentation from pkg.go.dev to LLMs as an MCP server.

    godoc-mcp-server enables searching Golang packages and obtains their documentation from pkg.go.dev, serving the information to language models via the Model Context Protocol. Communication occurs over standard input/output, supporting efficient retrieval of package information, including support for subpackages and usage instructions. The tool includes local caching and features tailored to LLM integration scenarios.

    • 32
    • MCP
    • yikakia/godoc-mcp-server
  • GitHub MCP Server

    GitHub MCP Server

    Connect AI tools directly to GitHub for repository, issue, and workflow management via natural language.

    GitHub MCP Server enables AI tools such as agents, assistants, and chatbots to interact natively with the GitHub platform. It allows these tools to access repositories, analyze code, manage issues and pull requests, and automate workflows using the Model Context Protocol (MCP). The server supports integration with multiple hosts, including VS Code and other popular IDEs, and can operate both remotely and locally. Built for developers seeking to enhance AI-powered development workflows through seamless GitHub context access.

    • 24,418
    • MCP
    • github/github-mcp-server
  • Neovim MCP Server

    Neovim MCP Server

    Connect AI assistants to Neovim via the Model Context Protocol.

    Neovim MCP Server enables seamless integration between Neovim instances and AI assistants by implementing the Model Context Protocol (MCP). It allows for multi-connection management, supports both stdio and HTTP server transport modes, and provides access to structured diagnostic information via URI schemes. With LSP integration, plugin support, and an extensible tool system, it facilitates advanced interaction with Neovim for context-aware AI workflows.

    • 20
    • MCP
    • linw1995/nvim-mcp
  • PMCP

    PMCP

    Golang Model Context Protocol server for natural language Prometheus queries

    PMCP implements a Model Context Protocol (MCP) server in Go, enabling natural language access and manipulation of Prometheus metrics. It maintains full consistency with the Prometheus HTTP API and supports a robust, type-safe interface for seamless integration with MCP-compatible clients. The server offers complete Prometheus API coverage and supports multiple transport methods, including HTTP and Server-Sent Events. Its modular architecture is designed for performance, extensibility, and effective error handling.

    • 3
    • MCP
    • yshngg/pmcp
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results