Airsc miễn phí cho tất cả. Nếu nó giúp bạn, hãy ủng hộ $2–$20.

Ủng hộ
MCP serverAn toànReview & chất lượng codeCần cài đặt chút

mcp-language-server

isaacphi · isaacphi/mcp-language-server

Máy chủ MCP này cho phép các tác nhân AI truy cập các công cụ mã ngữ nghĩa như tra cứu định nghĩa, tìm tham chiếu, đổi tên và chẩn đoán để điều hướng cơ sở mã dễ dàng hơn.

mcp-language-server cung cấp cho các máy khách hỗ trợ MCP quyền truy cập vào các công cụ ngữ nghĩa như lấy định nghĩa, tham chiếu, đổi tên và chẩn đoán.

1.6k sao149Giấy phép: BSD-3-ClauseCập nhật 8 tháng trước0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Tìm tất cả các tham chiếu đến một biến hoặc hàm trong cơ sở mã.
  • Lấy định nghĩa của một hàm lạ mà tác nhân gặp phải.
  • Xác định và sửa lỗi hoặc chẩn đoán mã được báo cáo bởi máy chủ ngôn ngữ.

Kiểm tra an toàn

An toàn

Không thấy dấu hiệu rủi ro trong các file đã quét.

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ README

MCP Language Server

This is an MCP server that runs and exposes a language server to LLMs. Not a language server for MCP, whatever that would be.

Demo

mcp-language-server helps MCP enabled clients navigate codebases more easily by giving them access semantic tools like get definition, references, rename, and diagnostics.

Setup

  1. Install Go: Follow instructions at https://golang.org/doc/install
  2. Install or update this server: go install github.com/isaacphi/mcp-language-server@latest
  3. Install a language server: follow one of the guides below
  4. Configure your MCP client: follow one of the guides below

Go (gopls)

<strong>Install gopls</strong>: <code>go install golang.org/x/tools/gopls@latest</code>
<strong>Configure your MCP client</strong>: This will be different but similar for each client. For Claude Desktop, add the following to <code>~/Library/Application\ Support/Claude/claude_desktop_config.json</code>

{ "mcpServers": { "language-server": { "command": "mcp-language-server", "args": ["--workspace", "/Users/you/dev/yourproject/", "--lsp", "gopls"], "env": { "PATH": "/opt/homebrew/bin:/Users/you/go/bin", "GOPATH": "/users/you/go", "GOCACHE": "/users/you/Library/Caches/go-build", "GOMODCACHE": "/Users/you/go/pkg/mod" } } } }

Note: Not all clients will need these environment variables. For Claude Desktop you will need to update the environment variables above based on your machine and username:

Rust (rust-analyzer)

<strong>Install rust-analyzer</strong>: <code>rustup component add rust-analyzer</code>
<strong>Configure your MCP client</strong>: This will be different but similar for each client. For Claude Desktop, add the following to <code>~/Library/Application\ Support/Claude/claude_desktop_config.json</code>

{ "mcpServers": { "language-server": { "command": "mcp-language-server", "args": [ "--workspace", "/Users/you/dev/yourproject/", "--lsp", "rust-analyzer" ] } } }

Python (pyright)

<strong>Install pyright</strong>: <code>npm install -g pyright</code>
<strong>Configure your MCP client</strong>: This will be different but similar for each client. For Claude Desktop, add the following to <code>~/Library/Application\ Support/Claude/claude_desktop_config.json</code>

{ "mcpServers": { "language-server": { "command": "mcp-language-server", "args": [ "--workspace", "/Users/you/dev/yourproject/", "--lsp", "pyright-langserver", "--", "--stdio" ] } } }

Typescript (typescript-language-server)

<strong>Install typescript-language-server</strong>: <code>npm install -g typescript typescript-language-server</code>
<strong>Configure your MCP client</strong>: This will be different but similar for each client. For Claude Desktop, add the following to <code>~/Library/Application\ Support/Claude/claude_desktop_config.json</code>

{ "mcpServers": { "language-server": { "command": "mcp-language-server", "args": [ "--workspace", "/Users/you/dev/yourproject/", "--lsp", "typescript-language-server", "--", "--stdio" ] } } }

C/C++ (clangd)

<strong>Install clangd</strong>: Download prebuilt binaries from the official LLVM releases page or install via your system's package manager (e.g., <code>apt install clangd</code>, <code>brew install clangd</code>).
<strong>Configure your MCP client</strong>: This will be different but similar for each client. For Claude Desktop, add the following to <code>~/Library/Application\\ Support/Claude/claude_desktop_config.json</code>

{ "mcpServers": { "language-server": { "command": "mcp-language-server", "args": [ "--workspace", "/Users/you/dev/yourproject/", "--lsp", "/path/to/your/clangd_binary", "--", "--compile-commands-dir=/path/to/yourproject/build_or_compile_commands_dir" ] } } } Note: Replace /path/to/your/clangd_binary with the actual path to your clangd executable. --compile-commands-dir should point to the directory containing your compile_commands.json file (e.g., ./build, ./cmake-build-debug). Ensure compile_commands.json is generated for your project for clangd to work effectively.

Other

I have only tested this repo with the servers above but it should be compatible with many more. Note:
<ul>
  <li>The language server must communicate over stdio.</li>
  <li>Any aruments after <code>--</code> are sent as arguments to the language server.</li>
  <li>Any env variables are passed on to the language server.</li>
</ul>

Tools

  • definition: Retrieves the complete source code definition of any symbol (function, type, constant, etc.) from your codebase.
  • references: Locates all usages and references of a symbol throughout the codebase.
  • diagnostics: Provides diagnostic information for a specific file, including warnings and errors.
  • hover: Display documentation, type hints, or other hover information for a given location.
  • rename_symbol: Rename a symbol across a project.
  • edit_file: Allows making multiple text e
Xem mã nguồn trên GitHub