Language Server MCP server

Provides intelligent code analysis and manipulation across multiple programming languages through language server protocols, enabling developers to explore, understand, and refactor complex codebases.
Back to servers
Provider
Phil Isaac
Release date
Dec 31, 2024
Language
Go
Stats
490 stars

The MCP Language Server enables LLMs to navigate codebases using semantic tools like definitions, references, rename capabilities, and diagnostics through the Language Server Protocol.

Installation

To get started with the MCP Language Server:

  1. Install Go by following the instructions at https://golang.org/doc/install
  2. Install the MCP Language Server with:
    go install github.com/isaacphi/mcp-language-server@latest
    
  3. Install a language server for your programming language (see options below)
  4. Configure your MCP client to use the server

Setting Up Language Servers

Go (gopls)

Install gopls:

go install golang.org/x/tools/gopls@latest

Configure your MCP client (example for Claude Desktop):

{
  "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: You'll need to update environment variables based on your machine. The PATH should include the path to both go and gopls. You can find these with echo $(which go):$(which gopls).

Rust (rust-analyzer)

Install rust-analyzer:

rustup component add rust-analyzer

Configure your MCP client:

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

Python (pyright)

Install pyright:

npm install -g pyright

Configure your MCP client:

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

TypeScript (typescript-language-server)

Install typescript-language-server:

npm install -g typescript typescript-language-server

Configure your MCP client:

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

C/C++ (clangd)

Install clangd by downloading prebuilt binaries from the official LLVM releases page or install via your system's package manager.

Configure your MCP client:

{
  "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. The --compile-commands-dir should point to the directory containing your compile_commands.json file.

Available Tools

The MCP Language Server provides several useful tools:

  • definition: Gets the complete source code definition of any symbol (function, type, constant, etc.)
  • references: Finds all usages and references of a symbol throughout the codebase
  • diagnostics: Provides warnings and errors for a specific file
  • hover: Displays documentation, type hints, or other hover information
  • rename_symbol: Renames a symbol across a project
  • edit_file: Makes multiple text edits to a file based on line numbers

Debugging

To enable verbose logging, set the LOG_LEVEL environment variable to DEBUG in your MCP client configuration:

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

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later