mcp-gopls
MCP server bridging Go's LSP and AI assistants for advanced code analysis.
Key Features
Use Cases
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
.
├── 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
go install github.com/hloiseaufcms/mcp-gopls/cmd/mcp-gopls@latest
Add to Cursor
{
"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:
# 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
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:
- Make sure Ollama is running
- The MCP server runs independently and communicates through stdin/stdout
- Configure your client to use the MCP server as a tool provider
License
Apache License 2.0
Star History
Repository Owner
User
Repository Details
Programming Languages
Tags
Join Our Newsletter
Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.
Related MCPs
Discover similar Model Context Protocol servers
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
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
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
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
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
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?