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.
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
To add the MCP server to Cursor, add the following configuration:
{
"mcpServers": {
"mcp-gopls": {
"command": "mcp-gopls"
}
}
}
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 |
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.
This MCP server can be used with any tool that supports the MCP protocol. For example, with Ollama:
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.
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"
]
}
}
}
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.
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.