A Model Context Protocol (MCP) server that lets AI assistants interact with Go’s Language Server Protocol (gopls) for advanced code analysis (definitions, references, diagnostics, hover, completion, etc.).
https://github.com/hloiseaufcms/mcp-goplsStop watching AI assistants fumble through Go code analysis when they could be using the same tools you rely on every day. This MCP server connects your AI assistant directly to gopls — Go's official language server — giving it access to the same precise code analysis that powers your IDE.
When you're working with AI on Go projects, you've probably noticed the gap. Your IDE knows exactly where that function is defined, what errors exist, and what completions make sense. Your AI assistant? It's making educated guesses based on static text analysis.
mcp-gopls eliminates that gap by giving AI assistants direct access to Go's language server protocol. Now when you ask "where is this function defined?" or "what errors are in this file?", your AI gets the same authoritative answers that gopls provides to VS Code, GoLand, or any other Go-aware editor.
Precise Code Navigation: Ask your AI to find definitions, references, or implementations. It'll use the same symbol resolution that your IDE uses — no more hunting through files manually.
Real-Time Diagnostics: Get immediate feedback on compilation errors, type mismatches, and other issues without running go build. Your AI can spot problems and suggest fixes using actual compiler feedback.
Context-Aware Completions: When your AI suggests code, it's backed by the same completion engine that knows your project's types, methods, and available imports.
Test Coverage Analysis: Understanding which parts of your code need testing becomes a conversation with your AI rather than a manual analysis task.
Here's how this transforms your daily Go development:
Code Review Assistance: "Check this function for any issues" now returns actual diagnostics from gopls, not generic advice.
Refactoring Support: "Find all references to this type" gives you precise locations across your entire project, making large refactors safer.
Documentation Generation: "Explain what this function does" can include hover information and type details that gopls provides, resulting in more accurate documentation.
Debugging Help: When troubleshooting, your AI can analyze code paths and dependencies using the same symbol resolution your debugger uses.
Install the server:
go install github.com/hloiseaufcms/mcp-gopls/cmd/mcp-gopls@latest
Add it to your MCP-enabled client (like Cursor):
{
"mcpServers": {
"mcp-gopls": {
"command": "mcp-gopls"
}
}
}
That's it. Your AI assistant now has professional-grade Go analysis capabilities.
This server acts as a bridge between the Model Context Protocol and Go's language server protocol. It maintains a persistent connection to gopls, translating MCP requests into LSP operations and streaming responses back to your AI assistant.
The architecture is straightforward: MCP requests come in, get translated to LSP calls, gopls processes them using your actual Go workspace, and results flow back through the MCP response. This means your AI is working with the same workspace state and module information that your development tools use.
gopls installed (standard with modern Go installations)The server runs locally and requires no external dependencies or cloud services. Your code analysis happens entirely within your development environment, maintaining the same security and privacy you expect from local development tools.
Ready to give your AI assistant the same Go analysis capabilities you use every day? Install mcp-gopls and start having more productive conversations about your Go code.