Skip to main content
Glama

MCP Language Server

MCP 语言服务器

这是一个运行语言服务器并向 LLM 开放的MCP服务器。它不是 MCP 的语言服务器,无论 MCP 是什么。

演示

mcp-language-server通过为启用 MCP 的客户端提供访问语义工具(如获取定义、引用、重命名和诊断)来帮助它们更轻松地导航代码库。

演示

设置

  1. 安装 Go :按照https://golang.org/doc/install上的说明进行操作
  2. 安装或更新此服务器go install github.com/isaacphi/mcp-language-server@latest
  3. 安装语言服务器按照以下指南之一进行操作
  4. 配置您的 MCP 客户端请按照以下指南之一进行操作
<p><strong>Note</strong>:</p> <ul> <li>Replace <code>/path/to/your/clangd_binary</code> with the actual path to your clangd executable.</li> <li><code>--compile-commands-dir</code> should point to the directory containing your <code>compile_commands.json</code> file (e.g., <code>./build</code>, <code>./cmake-build-debug</code>).</li> <li>Ensure <code>compile_commands.json</code> is generated for your project for clangd to work effectively.</li> </ul>

工具

  • definition :从代码库中检索任何符号(函数、类型、常量等)的完整源代码定义。
  • references :在整个代码库中定位符号的所有用法和引用。
  • diagnostics :提供特定文件的诊断信息,包括警告和错误。
  • hover :显示给定位置的文档、类型提示或其他悬停信息。
  • rename_symbol :在项目中重命名符号。
  • edit_file :允许根据行号对文件进行多项文本编辑。与基于搜索和替换的编辑工具相比,它提供了一种更可靠、更经济的文件编辑方式。

关于

此代码库使用gopls编辑的代码来处理 LSP 通信。详情请参阅 ATTRIBUTION。此处所有内容均受 BSD 风格许可证的保护。

mcp-go用于 MCP 通信。感谢您的服务。

这是测试版软件。如果您遇到任何问题或有任何建议,请通过创建问题来告知我。

贡献

请保持 PR 规模较小,并优先开放 Issues 以应对任何实质性问题。AI 漏洞只要经过测试、检查,且问题不大,就没问题。

设置

克隆仓库:

git clone https://github.com/isaacphi/mcp-language-server.git cd mcp-language-server

为了方便起见,包含了一个justfile

just -l Available recipes: build # Build check # Run code audit checks fmt # Format code generate # Generate LSP types and methods help # Help install # Install locally snapshot # Update snapshot tests test # Run tests

配置您的 Claude Desktop(或类似桌面)以使用本地二进制文件:

{ "mcpServers": { "language-server": { "command": "/full/path/to/your/clone/mcp-language-server/mcp-language-server", "args": [ "--workspace", "/path/to/workspace", "--lsp", "language-server-executable" ], "env": { "LOG_LEVEL": "DEBUG" } } } }

进行更改后重建。

日志记录

LOG_LEVEL环境变量设置为 DEBUG 可将所有组件的详细日志记录到 stderr,包括往返于语言服务器的消息以及语言服务器的日志。

LSP 交互

  • internal/lsp/methods.go包含用于调用所连接的语言服务器的生成代码。
  • internal/protocol/tsprotocol.go包含 LSP 类型的生成代码。我从gopls的源代码中借鉴了这些代码。感谢您的服务。
  • LSP 允许语言服务器为相同的方法返回不同的类型。Go 语言不支持这种做法,因此在internal/protocol/interfaces.go中引入了一些不太好用的变通方法。

本地开发和快照测试

有一个快照测试套件,可以更轻松地测试工具的更改。它们在模拟工作区上运行真实的语言服务器,并捕获输出和日志。

您需要在本地安装语言服务器才能运行它们。这里有针对 Go、Rust、Python 和 TypeScript 的测试。

integrationtests/ ├── tests/ # Tests are in this folder ├── snapshots/ # Snapshots of tool outputs ├── test-output/ # Gitignored folder showing the final state of each workspace and logs after each test run └── workspaces/ # Mock workspaces that the tools run on

要更新快照,请运行UPDATE_SNAPSHOTS=true go test ./integrationtests/...

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

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

运行语言服务器并提供与其通信的工具。语言服务器擅长处理法学硕士 (LLM) 经常遇到的难题,例如精确理解类型、理解关系以及提供准确的符号引用。

  1. 演示
    1. 设置
      1. 工具
        1. 关于
          1. 贡献
            1. 设置
            2. 日志记录
            3. LSP 交互
            4. 本地开发和快照测试

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            This is a server that lets your LLMs (like Claude) talk directly to your BigQuery data! Think of it as a friendly translator that sits between your AI assistant and your database, making sure they can chat securely and efficiently.
            Last updated -
            1
            241
            81
            JavaScript
            MIT License
          • A
            security
            A
            license
            A
            quality
            This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.
            Last updated -
            1
            54,491
            JavaScript
            MIT License
            • Linux
            • Apple
          • -
            security
            F
            license
            -
            quality
            A TypeScript-based server that provides a memory system for Large Language Models (LLMs), allowing users to interact with multiple LLM providers while maintaining conversation history and offering tools for managing providers and model configurations.
            Last updated -
            20
            JavaScript
            • Apple
          • -
            security
            F
            license
            -
            quality
            This server provides an API to query Large Language Models using context from local files, supporting various models and file types for context-aware responses.
            Last updated -
            1
            TypeScript

          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/isaacphi/mcp-language-server'

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