Cursor Setup
Configure gopls-mcp with Cursor IDE.
Setup gopls-mcp for Your Project
Section titled “Setup gopls-mcp for Your Project”Ensure Cursor is installed, and gopls-mcp is already installed on your system.
Configure MCP Server
Section titled “Configure MCP Server”Cursor uses JSON configuration files to manage MCP servers. You can configure gopls-mcp at either the project level or global level.
Option 1: Project-Level Configuration (Recommended)
Section titled “Option 1: Project-Level Configuration (Recommended)”Create or edit .cursor/mcp.json in your project root:
# Create the directory if it doesn't existmkdir -p .cursorThen add the following configuration to .cursor/mcp.json:
{ "mcpServers": { "gopls-mcp": { "command": "gopls-mcp" } }}If the file already exists, add the
"gopls-mcp"entry to the existingmcpServersobject.
Option 2: Global Configuration
Section titled “Option 2: Global Configuration”Configure gopls-mcp for all projects by creating ~/.cursor/mcp.json:
# Create the directory if it doesn't existmkdir -p ~/.cursorThen add the same configuration to ~/.cursor/mcp.json.
If the file already exists, add the
"gopls-mcp"entry to the existingmcpServersobject.
Note: Project-level configuration takes precedence over global configuration.
Configure Project Instructions (.cursorrules)
Section titled “Configure Project Instructions (.cursorrules)”Cursor needs specific instructions to know when to use the semantic tools. Run this command in your project root:
curl -sL https://gopls-mcp.org/gopls-mcp.prompt >> .cursorrulesThis creates a .cursorrules file in your project directory with instructions for Cursor to use gopls-mcp tools effectively.
Verify gopls-mcp
Section titled “Verify gopls-mcp”-
Open Cursor Settings:
- Click the gear icon in the top-right corner
- Go to Tools & MCP
-
Enable gopls-mcp Server:
- You should see
gopls-mcpin the server list - Click the toggle to enable it (it may be disabled by default)
- The status indicator should turn green
- You should see
Auto-Approve MCP Tool Calls
Section titled “Auto-Approve MCP Tool Calls”By default, Cursor asks for confirmation before each MCP tool call. To automatically approve all gopls-mcp tool calls:
- Go to Settings → Agents → MCP Allowlists
- Add
gopls-mcp:*to the allowlist
This allows Cursor to execute all gopls-mcp tools without manual confirmation.
Security Note: Only configure MCP allowlists in trusted projects. Keep Cursor updated to the latest version to ensure security patches are applied.
- Test with Agent (Composer):
- Open a new Agent (Composer) conversation
- Try a Go-related task like:
- “Find all implementations of the
Handlerinterface” - “Show me the call hierarchy for the
ServeHTTPmethod”
- “Find all implementations of the
- Cursor should automatically use gopls-mcp tools
Important: MCP tools are only available in Agent (Composer) mode. The regular Ask (Chat) mode does not support MCP calls. If you see a message like “gopls-mcp MCP calls are limited in Ask mode”, switch to Agent (Composer) to use gopls-mcp tools.
Troubleshooting
Section titled “Troubleshooting”Server not showing up?
- Check that the configuration file is valid JSON
- Try toggling the server on/off in Cursor Settings
- Restart Cursor to reload the configuration
Server status is red?
- Click “View Logs” next to the server to see error messages
- Verify
gopls-mcpis installed and in your PATH:Terminal window which gopls-mcpgopls-mcp --version
Agent not using gopls-mcp tools?
- Make sure you’re using Agent (Composer), not regular Chat
- Check that
.cursorrulesexists in your project root - Try explicitly mentioning Go-related tasks