LSP MCP Server

Bridges Claude Code to Language Server Protocol (LSP) servers

README.md

lsp-mcp-server

An MCP (Model Context Protocol) server that bridges Claude Code to Language Server Protocol (LSP) servers, enabling semantic code intelligence capabilities.

Overview

lsp-mcp-server acts as a bridge between Claude Code and language servers, providing powerful code intelligence features:

  • Go to Definition - Navigate to where symbols are defined
  • Find References - Find all usages of a symbol across the workspace
  • Hover Information - Get type information and documentation
  • Code Completion - Get intelligent code suggestions
  • Diagnostics - Access errors, warnings, and hints from the language server
  • Symbol Search - Search for symbols in documents or across the workspace
  • Rename - Safely rename symbols across the entire codebase
  • Code Actions - Apply quick fixes, refactorings, and organize imports
  • Call Hierarchy - See who calls a function and what it calls
  • Type Hierarchy - Explore class inheritance and interface implementations
  • Format Document - Format code using the language server's formatter
  • Smart Search - Comprehensive symbol analysis in a single call
  • File Analysis - Explore imports, exports, and file relationships
┌─────────────┐      ┌──────────────────┐      ┌───────────────────┐
│ Claude Code │────▶│  lsp-mcp-server  │────▶│ Language Servers  │
│   (MCP)     │◀────│   (this tool)    │◀────│ (TypeScript, etc) │
└─────────────┘      └──────────────────┘      └───────────────────┘
      stdio              stdio/JSON-RPC            stdio

Features

  • 24 MCP Tools for comprehensive code intelligence
  • 10 Languages Supported out of the box:
    • TypeScript / JavaScript
    • Python
    • Rust
    • Go
    • C / C++
    • Ruby
    • PHP
    • Elixir
    • Kotlin
    • Java
  • Multi-root Workspace - Proper monorepo support with per-workspace server instances
  • Push-based Diagnostics - Real-time error/warning caching from language servers
  • Human-friendly Positions - All line/column numbers are 1-indexed
  • Safe Rename - Preview changes before applying with dry-run mode
  • Automatic Server Management - Servers start on-demand and restart on crash
  • Configurable - Customize language servers, timeouts, and more
  • Security Features - File size limits, workspace boundary validation, absolute path enforcement

Installation

Prerequisites

  • Node.js 18.0.0 or higher
  • Language servers for the languages you want to use:
# TypeScript/JavaScript
npm install -g typescript-language-server typescript

# Python
pip install python-lsp-server

# Rust
rustup component add rust-analyzer

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

# C/C++
# Ubuntu/Debian:
sudo apt install clangd
# macOS:
brew install llvm

# Ruby
gem install solargraph

# PHP
npm install -g intelephense

# Elixir
mix escript.install hex elixir_ls
# Or download pre-built releases from:
# https://github.com/elixir-lsp/elixir-ls/releases

# Kotlin
# macOS:
brew install JetBrains/utils/kotlin-lsp
# Or download from:
# https://github.com/Kotlin/kotlin-lsp/releases

# Java (requires Java 20+, Maven, npm, protobuf)
git clone https://github.com/idelice/jls
cd jls && ./scripts/build.sh
# Add dist/ to PATH or symlink dist/lang_server_linux.sh as 'jls'

Install lsp-mcp-server

# Clone the repository
git clone <repository-url>
cd lsp-mcp-server

# Install dependencies
npm install

# Build
npm run build

# Verify installation
node dist/index.js --help

Global Installation (Optional)

# Link globally for easy access
npm link

# Now you can run from anywhere
lsp-mcp-server

Configuration with Claude Code

1. Add to Claude Code MCP Settings

Create or edit the .mcp.json file in your home directory:

Location: ~/.mcp.json (user-level) or .mcp.json in your project root (project-level)

{
  "mcpServers": {
    "lsp": {
      "command": "node",
      "args": ["/absolute/path/to/lsp-mcp-server/dist/index.js"],
      "env": {
        "LSP_LOG_LEVEL": "info"
      }
    }
  }
}

Or if installed globally via npm link:

{
  "mcpServers": {
    "lsp": {
      "command": "lsp-mcp-server"
    }
  }
}

2. Restart Claude Code

After updating the configuration, restart Claude Code to load the new MCP server.

3. Verify Installation

In Claude Code, ask:

"Use lsp_server_status to check available language servers"

You should see a response showing the server is running.

4. Enforce LSP Tool Usage (Recommended)

To make Claude Code consistently prefer LSP tools over alternatives like Grep and Glob for code navigation, add instructions to your global ~/.claude/CLAUDE.md file:

## LSP Server - REQUIRED FIRST STEP

**BEFORE any code analysis, navigation, or codebase exploration, you MUST:**

1. Run `lsp_server_status` to check running servers
2. If the relevant language server is NOT running → run `lsp_start_server` immediately
3. ONLY AF

Tools 2

lsp_server_statusCheck available and running language servers
lsp_start_serverStart a language server for a specific language

Environment Variables

LSP_LOG_LEVELSets the logging verbosity (e.g., info, debug)

Try it

Use lsp_server_status to check which language servers are currently running.
Find all references to the 'User' class in my project using the LSP server.
Rename the function 'calculateTotal' to 'computeTotal' safely across the codebase.
Show me the call hierarchy for the 'processData' function.
Run lsp_start_server to initialize the Python language server for this workspace.

Frequently Asked Questions

What are the key features of LSP MCP Server?

Supports 10+ languages including TypeScript, Python, Rust, Go, and C++. Enables semantic features like Go to Definition, Find References, and Rename. Provides real-time diagnostics and error reporting from language servers. Supports multi-root workspaces for monorepo development. Includes automatic server management and crash recovery.

What can I use LSP MCP Server for?

Navigating complex codebases with deep symbol resolution. Performing safe, project-wide refactoring with symbol renaming. Debugging code issues using real-time diagnostics from language servers. Exploring class inheritance and interface implementations in large projects.

How do I install LSP MCP Server?

Install LSP MCP Server by running: git clone https://github.com/ProfessioneIT/lsp-mcp-server && cd lsp-mcp-server && npm install && npm run build

What MCP clients work with LSP MCP Server?

LSP MCP Server works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep LSP MCP Server docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Open Conare