Skip to main content
Glama

MCP LSP 转到

模型上下文协议 (MCP) 服务器允许像 Claude 这样的 AI 助手与 Go 的语言服务器协议 (LSP) 交互并受益于高级 Go 代码分析功能。

概述

该 MCP 服务器可帮助 AI 助手:

  • 使用 LSP 分析 Go 代码

  • 导航至定义并查找参考

  • 检查代码诊断

  • 获取符号的悬停信息

  • 获取完成建议

建筑学

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

该服务器通过语言服务器协议(LSP)与 Go 的官方语言服务器gopls进行通信。

特征

  • LSP 集成:连接到 Go 的语言服务器协议进行代码分析

  • 代码导航:在代码中查找定义和引用

  • 代码质量:获取诊断和错误

  • 高级信息:悬停信息和完成建议

项目结构

. ├── cmd │ └── mcp-gopls # Application entry point ├── pkg │ ├── lsp # LSP client to communicate with gopls │ │ ├── client # LSP client implementation │ │ └── protocol # LSP protocol types and features │ ├── server # MCP server │ └── tools # MCP tools exposing LSP features

安装

go install github.com/hloiseaufcms/mcp-gopls/cmd/mcp-gopls@latest

添加到光标

{ "mcpServers": { "mcp-gopls": { "command": "mcp-gopls" } } }

MCP 工具

MCP 服务器提供以下工具:

工具

描述

go_to_definition

导航到符号的定义

find_references

查找对符号的所有引用

check_diagnostics

获取文件诊断信息

get_hover_info

获取有关符号的详细信息

get_completion

获取某个位置的完成建议

analyze_coverage

分析 Go 代码的测试覆盖率

使用示例

将服务器与支持 MCP 的 AI 助手一起使用:

# Ask the AI to get information about the code Can you find the definition of the `ServeStdio` function in this project? # Ask for diagnostics Are there any errors in my main.go file? # Ask for information about a symbol What does the Context.WithTimeout function do in Go?

发展

git clone https://github.com/hloiseaufcms/mcp-gopls.git cd mcp-gopls go mod tidy go build -o mcp-gopls cmd/mcp-gopls/main.go ./mcp-gopls

先决条件

  • Go 1.24 或更高版本

  • gopls 已安装( go install golang.org/x/tools/gopls@latest

执照

Apache 许可证 2.0

-
security - not tested
A
license - permissive license
-
quality - not tested

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    A Model Context Protocol (MCP) server that allows AI agents like Claude to interact with the Aligo SMS API to send text messages and retrieve related information.
    Last updated -
    1
    MIT License
  • A
    security
    A
    license
    A
    quality
    A Model Context Protocol (MCP) server for LeetCode that enables AI assistants to access LeetCode problems, user information, and contest data.
    Last updated -
    7
    9
    35
    MIT License
  • A
    security
    A
    license
    A
    quality
    A foundation for building custom local Model Context Protocol (MCP) servers that provide tools accessible to AI assistants like Cursor or Claude Desktop.
    Last updated -
    1
    31
    MIT License
  • A
    security
    F
    license
    A
    quality
    A Model Context Protocol (MCP) server that allows Claude AI to interact with custom tools, enabling extension of Claude's capabilities through the MCP framework.
    Last updated -
    • Apple

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/hloiseaufcms/mcp-gopls'

If you have feedback or need assistance with the MCP directory API, please join our Discord server