HM

hloiseau/mcp-gopls

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

104 stars 11 forks 质量 82 趋势 4Apache-2.0

hloiseau/mcp-gopls 是从 https://github.com/hloiseau/mcp-gopls. 导入的 MCP 服务器候选。

概览

hloiseau/mcp-gopls 是从 https://github.com/hloiseau/mcp-gopls. 导入的 MCP 服务器候选。

概述(AI 翻译)

一个模型上下文协议(MCP)服务器,允许AI助手使用Go的LSP(gopls)进行导航、诊断、测试、覆盖等。

TL;DR: 如果你用 Claude / Cursor / Copilot 配合 Go 操作,mcp-gopls 会给 AI 完整的 LSP 能力: 定义、参考、悬停、完成、go test、覆盖、go mod tidy、govulncheck等。

概述

该MCP服务器帮助AI助手:

  • 使用逻辑分析器分析 Go 工作区
  • 导航至定义、引用和工作区符号
  • 格式化、重命名和检查代码动作,无需离开MCP
  • 运行 Go 测试、覆盖率、go mod tidy、govulncheck及模块图命令,并带有结构化结果
  • 阅读工作区资源(概览 + go.mod)并阅读精选提示

状态: 积极开发——用于实际项目。 用Go 1.25.x和gopls@latest测试过。

建筑

该项目使用 mark3labs/mcp-go 库实现模型上下文协议。MCP 集成实现了 AI 助手与围棋工具之间的无缝通信。

服务器通过语言服务器协议(LSP)与Gopls(Go的官方语言服务器)通信。

特色

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

mcp-gopls – MCP server for Go (gopls)

A Model Context Protocol (MCP) server that lets AI assistants use Go’s LSP (gopls) for navigation, diagnostics, testing, coverage, and more.

TL;DR: If you use Claude / Cursor / Copilot with Go, mcp-gopls gives the AI full LSP powers: go-to-definition, references, hover, completion, go test, coverage, go mod tidy, govulncheck, etc.

Overview

This MCP server helps AI assistants to:

  • Use LSP to analyze Go workspaces
  • Navigate to definitions, references, and workspace symbols
  • Format, rename, and inspect code actions without leaving MCP
  • Run Go tests, coverage, go mod tidy, govulncheck, and module graph commands with structured results
  • Read workspace resources (overview + go.mod) and consume curated prompts

Status: Actively developed – used in real projects.
Tested with Go 1.25.x and gopls@latest.

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

  • Configurable runtime: --workspace, --gopls-path, --log-level, --rpc-timeout, and --shutdown-timeout flags + env vars (MCP_GOPLS_*)
  • Structured logging: Text/JSON logging with slog and optional file output
  • Extended LSP surface: navigation, diagnostics, formatting, rename, code actions, hover, completion, workspace symbols
  • Test & tooling helpers: coverage analysis, go test, go mod tidy, govulncheck, go mod graph
  • MCP extras: resources (resource://workspace/overview, resource://workspace/go.mod) and prompts (summarize_diagnostics, refactor_plan)
  • Progress streaming: long-running commands emit notifications/progress events so clients can surface status updates

Feature comparison: mcp-gopls vs built-in gopls MCP

As of gopls v0.20.0, the built-in MCP server exposes these tools: go_context, go_diagnostics, go_file_context, go_file_diagnostics, go_file_metadata, go_package_api, go_references, go_rename_symbol, go_search, go_symbol_references, go_workspace, go_vulncheck.

| Feature / capability | mcp-gopls (this project) | Built-in gopls MCP |

在 GitHub 查看完整 README

安装

docker run --rm -i \
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mcp-gopls": { "command": "mcp-gopls", "args": ["--workspace", "/absolute/path/to/your/go/project"], "env": { "MCP_GOPLS_LOG_LEVEL": "info" } } } }