Provides semantic code intelligence for C++ projects, including navigation, code completion, diagnostics, and refactoring through clangd.
Provides semantic code intelligence for Elixir projects, including navigation, completion, and diagnostics using ElixirLS.
Provides semantic code intelligence for JavaScript projects, including navigation, completion, and symbol search via the TypeScript Language Server.
Provides semantic code intelligence for PHP projects, including navigation, completion, and diagnostics using Intelephense.
Provides semantic code intelligence for Python projects, including navigation, completion, and diagnostics via the Python LSP server.
Provides semantic code intelligence for Ruby projects, including navigation, completion, and diagnostics using Solargraph.
Provides semantic code intelligence for Rust projects, including navigation, completion, and diagnostics using rust-analyzer.
Provides semantic code intelligence for TypeScript projects, including navigation, completion, symbol search, and refactoring via the TypeScript Language Server.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@lsp-mcp-serverFind all references to the validateInput function in src/utils.ts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Features
19 MCP Tools for comprehensive code intelligence
8 Languages Supported out of the box:
TypeScript / JavaScript
Python
Rust
Go
C / C++
Ruby
PHP
Elixir
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
Installation
Prerequisites
Node.js 18.0.0 or higher
Language servers for the languages you want to use:
Install lsp-mcp-server
Global Installation (Optional)
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)
Or if installed globally via npm link:
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.
Available Tools
Navigation Tools
lsp_goto_definition
Navigate to the definition of a symbol.
Example prompt: "Go to the definition of the function at line 42, column 10 in /project/src/utils.ts"
lsp_goto_type_definition
Navigate to the type definition of a symbol (useful for finding the interface/class that defines a variable's type).
Example prompt: "Find the type definition for the variable at line 15, column 5 in /project/src/app.ts"
Reference Tools
lsp_find_references
Find all references to a symbol across the workspace.
Example prompt: "Find all references to the 'UserService' class in /project/src/services/user.ts at line 5"
lsp_find_implementations
Find all implementations of an interface or abstract method.
Example prompt: "Find all implementations of the interface at line 10 in /project/src/types.ts"
Information Tools
lsp_hover
Get hover information (type info, documentation) for a symbol.
Example prompt: "What is the type of the variable at line 25, column 8 in /project/src/main.ts?"
lsp_signature_help
Get function/method signature information when inside a call expression.
Example prompt: "What are the parameters for the function call at line 30 in /project/src/api.ts?"
Symbol Tools
lsp_document_symbols
Get all symbols (functions, classes, variables, etc.) defined in a document.
Example prompt: "List all symbols in /project/src/components/Button.tsx"
lsp_workspace_symbols
Search for symbols across the entire workspace by name.
Example prompt: "Search for all classes containing 'Service' in the workspace"
Diagnostic Tools
lsp_diagnostics
Get cached diagnostics (errors, warnings) for a file.
Example prompt: "Show me all errors in /project/src/index.ts"
Completion Tools
lsp_completions
Get code completion suggestions at a position.
Example prompt: "What completions are available at line 15, column 10 in /project/src/app.ts?"
Refactoring Tools
lsp_rename
Rename a symbol across the workspace.
Example prompt: "Rename the function 'getUserData' to 'fetchUserData' at line 20 in /project/src/api.ts (dry run first)"
lsp_code_actions
Get available code actions (refactorings, quick fixes) at a position or range.
Example prompt: "What refactoring options are available for the function at line 50 in /project/src/utils.ts?"
lsp_format_document
Format a document using the language server's formatting capabilities.
Example prompt: "Format /project/src/messy-file.ts using the language server"
Hierarchy Tools
lsp_call_hierarchy
Get the call hierarchy for a function - who calls it and what it calls.
Example prompt: "Show me all functions that call handleRequest at line 100 in /project/src/server.ts"
lsp_type_hierarchy
Get the type hierarchy for a class or interface - supertypes and subtypes.
Example prompt: "What classes implement the Repository interface at line 5 in /project/src/types.ts?"
Combined Tools
lsp_smart_search
Comprehensive symbol search combining multiple LSP operations in one call.
Example prompt: "Give me a complete analysis of the processData function at line 75 in /project/src/processor.ts - definition, all references, and what calls it"
Server Management Tools
lsp_server_status
Get status of running language servers.
Example prompt: "Show the status of all language servers"
lsp_start_server
Manually start a language server for a specific workspace.
Example prompt: "Start the TypeScript language server for /home/user/my-project"
lsp_stop_server
Stop a running language server.
Example prompt: "Stop the Python language server"
Supported Languages
The following languages are supported out of the box:
Language | Server | Command | File Extensions | Root Patterns |
TypeScript/JavaScript | typescript-language-server |
|
|
|
Python | pylsp |
|
|
|
Rust | rust-analyzer |
|
|
|
Go | gopls |
|
|
|
C/C++ | clangd |
|
|
|
Ruby | solargraph |
|
|
|
PHP | intelephense |
|
|
|
Elixir | elixir-ls |
|
|
|
You can add additional languages by providing a custom configuration (see Configuration).
Configuration
Configuration File
Create a configuration file at one of these locations (in order of priority):
./.lsp-mcp.json(current directory)./lsp-mcp.json(current directory)~/.config/lsp-mcp/config.json(XDG config)~/.lsp-mcp.json(home directory)
Example configuration:
Configuration Options
Option | Type | Default | Description |
| array | Built-in defaults | Language server configurations |
| number | 30000 | Request timeout in milliseconds |
| boolean | true | Auto-start servers on first request |
| string | "info" | Log level: debug, info, warn, error |
| number | 1800000 | Idle timeout before stopping servers (30 min) |
Server Configuration
Each server in the servers array has:
Option | Type | Required | Description |
| string | Yes | Unique identifier for the server |
| string[] | Yes | File extensions this server handles |
| string[] | Yes | LSP language identifiers |
| string | Yes | Command to start the server |
| string[] | Yes | Command arguments |
| object | No | Environment variables |
| object | No | LSP initialization options |
| string[] | No | Files/dirs that indicate project root |
Environment Variables
Variable | Description |
| Override log level (debug, info, warn, error) |
| Override request timeout in milliseconds |
| Path to configuration file |
| Override workspace root detection |
Usage Examples with Claude Code
Basic Navigation
"I'm looking at /project/src/services/auth.ts. Can you tell me what the
validateTokenfunction at line 45 does? Use lsp_hover to get its documentation."
"Go to the definition of
UserRepositoryused at line 23, column 15 in /project/src/controllers/user.ts"
Finding Usages
"Find all places where the
handleErrorfunction is called in my codebase. It's defined at line 10 in /project/src/utils/error.ts"
"I want to refactor the
Configinterface. First, find all its implementations using lsp_find_implementations"
Code Quality
"Check /project/src/index.ts for any TypeScript errors using lsp_diagnostics"
"Show me all errors and warnings in /project/src/components/Form.tsx"
Safe Refactoring
"I want to rename the
getDatafunction tofetchData. It's at line 50 in /project/src/api.ts. First do a dry run to see what would change."
"The dry run looks good. Now apply the rename by setting dry_run to false."
Code Exploration
"List all the symbols in /project/src/models/User.ts to understand its structure"
"Search the workspace for all classes that contain 'Controller' in their name"
Completions
"What methods are available on the object at line 30, column 5 in /project/src/app.ts? Use lsp_completions"
Code Actions and Refactoring
"What refactoring options are available for the code selection from line 20 to 35 in /project/src/utils.ts?"
"Organize imports in /project/src/components/App.tsx using lsp_code_actions with kinds filter for source.organizeImports"
"Apply the quick fix for the error at line 15 in /project/src/api.ts"
Understanding Code Flow
"Show me the call hierarchy for the processOrder function at line 50 in /project/src/orders.ts - I want to see what calls it"
"What does the authenticate function call? Use lsp_call_hierarchy with outgoing direction"
"Show me the type hierarchy for the BaseRepository class - what are its subtypes?"
Comprehensive Analysis
"Give me a complete analysis of the UserService class at line 10 in /project/src/services/user.ts - I want definition, all references, implementations, and call hierarchy. Use lsp_smart_search"
Formatting
"Format /project/src/unformatted.ts using the language server (preview first, don't apply)"
Troubleshooting
Language Server Not Found
Error: Failed to start language server: typescript-language-server
Solution: Install the language server:
No Diagnostics Showing
Issue: lsp_diagnostics returns empty results
Explanation: Diagnostics are push-based. The language server sends them when files are opened or changed.
Solution:
Open the file using another tool first
Wait a moment for the server to analyze
Try again
Server Crashes Repeatedly
Issue: Server keeps crashing and restarting
Solution:
Check
LSP_MCP_LOG_LEVEL=debugfor detailed logsVerify the language server is properly installed
Check if the workspace has valid configuration (e.g., tsconfig.json for TypeScript)
Position Errors
Issue: "Invalid position" errors
Remember: All positions are 1-indexed (first line is 1, first column is 1), not 0-indexed.
Timeout Errors
Issue: Requests timing out
Solution: Increase the timeout:
Or in configuration:
Development
Building
Testing
Interactive Testing
Use the MCP Inspector for interactive testing:
Linting
Architecture
Multi-root Workspace Support
Server instances are keyed by (languageId, workspaceRoot) pairs. This means:
Each workspace gets its own language server instance
Monorepos work correctly with multiple tsconfig.json files
Server settings are isolated per workspace
Diagnostics Caching
Unlike other LSP features that are request-based, diagnostics are push-based:
Language servers send
publishDiagnosticsnotificationslsp-mcp-server caches these in memory
lsp_diagnosticstool reads from the cache
This means diagnostics are available immediately after files are opened, without an explicit request.
Automatic Server Lifecycle
Servers start automatically when needed (if
autoStart: true)Crashed servers restart with exponential backoff (max 3 attempts in 5 minutes)
Idle servers shut down after the configured timeout
License
MIT
Contributing
Contributions are welcome! Please read the contributing guidelines before submitting pull requests.