MCP LSP Go
An MCP server that connects AI assistants to Go's Language Server Protocol (LSP) for advanced code analysis.
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
Related Servers
Scout Monitoring MCP
sponsorPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
sponsorAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
Fluent (ServiceNow SDK)
Manage ServiceNow metadata, modules, records, and tests using Fluent, a TypeScript-based declarative DSL. Supports all ServiceNow SDK CLI commands.
Remote MCP Server on Cloudflare
A template for deploying a remote MCP server on Cloudflare Workers, allowing for custom tool integration.
FastAPI with MCP
A FastAPI application demonstrating MCP integration for mathematical operations and tool registration.
Qwen-Agent
A framework for developing LLM applications with capabilities like tool usage, planning, and memory, based on the Qwen model.
MockMCP
Create mock MCP servers instantly for developing and testing agentic AI workflows.
Accordo MCP Server
Provides dynamic YAML-driven workflow guidance for AI coding agents with structured development workflows, progression control, and decision points.
Gurobi MCP
Solve optimization problems formulated by an LLM using the on-device Gurobi solver.
MCP Development Server
Manage software development projects with full context awareness and Docker-based code execution.
APIMatic MCP
APIMatic MCP Server is used to validate OpenAPI specifications using APIMatic. The server processes OpenAPI files and returns validation summaries by leveraging APIMatic’s API.
Ghibli Video
Generates AI images and videos using the GPT4O Image Generator API.