yantrio/mcp-gopls 是从 https://github.com/yantrio/mcp-gopls. 导入的 MCP 服务器候选
概览
yantrio/mcp-gopls 是从 https://github.com/yantrio/mcp-gopls. 导入的 MCP 服务器候选
概述(AI 翻译)
一个MCP(模型上下文协议)服务器,将gopl包裹起来,提供Go语言服务器功能。
⚠️ 警告:整个项目由Claude代码生成,未经过人工代码审查。虽然通过测试且看起来功能正常,但请在生产环境中极度谨慎地使用。代码未经安全、性能或边缘情况审核。详见 DESIGN.md AI生成的设计文档。
特色
所有 gopls 语言服务器功能现已实现:
- GoToDefinition:导航到符号定义
- 查找参考文献:查找所有符号的引用
- GetDiagnostics:获取编译错误和静态分析结果
- 悬停:获取光标下方符号的信息
- SearchSymbol:在工作区中搜索符号(支持部分匹配)
- 重命名符号:在工作区中重命名符号(直接将更改应用到文件上)
- FindImplementers:查找所有实现接口的类型
- ListDocumentSymbols:获取文件中定义符号的大纲
- FormatCode:根据 gofmt 标准格式化 Go 源代码(对文件进行更改)
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCP-GOPLS
An MCP (Model Context Protocol) server that wraps gopls to provide Go language server features.
⚠️ WARNING: This entire project was generated by Claude Code without human code review. While it passes tests and appears functional, please use with EXTREME CAUTION in production environments. The code has not been audited for security, performance, or edge cases. See DESIGN.md for the AI-generated design document.
Features
All gopls language server features are now implemented:
- GoToDefinition: Navigate to the definition of a symbol
- FindReferences: Find all references to a symbol
- GetDiagnostics: Get compile errors and static analysis findings
- Hover: Get information about symbols under the cursor
- SearchSymbol: Search for symbols across the workspace (supports partial matching)
- RenameSymbol: Rename symbols across the workspace (applies changes directly to files)
- FindImplementers: Find all types that implement an interface
- ListDocumentSymbols: Get an outline of symbols defined in a file
- FormatCode: Format Go source code according to gofmt standards (applies changes to files)
- OrganizeImports: Organize import statements (groups and sorts imports, applies changes to files)
Installation
go install github.com/yantrio/mcp-gopls/cmd/mcp-gopls@latest
Integration with Claude
Claude Code
-
Install mcp-gopls:
go install github.com/yantrio/mcp-gopls/cmd/mcp-gopls@latest -
Add to Claude Code:
claude mcp add mcp-gopls "$(which mcp-gopls)" -
Restart Claude Code:
claude restart -
Verify installation:
claude mcp list
Claude Desktop
-
Install mcp-gopls (same as above)
-
Edit Claude Desktop configuration:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
- macOS:
-
Add the following to the
mcpServerssection:{ "mcpServers": { "mcp-gopls": { "command": "mcp-gopls", "args": [] } } }Or with custom workspace:
{ "mcpServers": { "mcp-gopls": { "command": "mcp-gopls", "args": ["-workspace", "/path/to/your/go/project"] } } } -
Restart Claude Desktop
Usage
# Run with default settings (uses gopls in PATH and current directory as workspace)
mcp-gopls
# Specify gopls path and workspace
mcp-gopls -gopls /path/to/gopls -workspace /path/to/project
# Using environment variables
export GOPLS_PATH=/path/to/gopls
export MCP_GOPLS_WORKSPACE=/path/to/project
mcp-gopls
Requirements
- Go 1.24.3+
- gopls (Go language server)
Installing gopls
go install golang.org/x/tools/gopls@latest
Development
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"mcp-gopls": {
"command": "mcp-gopls",
"args": []
}
}
}