lsp-mcp MCP Server
An MCP server that bridges LLMs and Language Server Protocol (LSP) servers, enabling LLMs to request hover information, code completions, diagnostics, and code actions for more accurate code suggestions.
Get this MCP server
An MCP server that bridges LLMs and Language Server Protocol (LSP) servers, enabling LLMs to request hover information, code completions, diagnostics, and code actions for more accurate code suggestions.
Installation
NPX
npx tritlo/lsp-mcp <language-id> <path-to-lsp> <lsp-args>
From Source
git clone https://github.com/your-username/lsp-mcp.git
cd lsp-mcp
npm install
npm run build
Configuration
MCP Configuration
{
"mcpServers": {
"lsp-mcp": {
"type": "stdio",
"command": "npx",
"args": [
"tritlo/lsp-mcp",
"<language-id>",
"<path-to-lsp>",
"<lsp-args>"
]
}
}
}
Available Tools
| Tool | Description |
|---|---|
get_info_on_location |
Get hover information at a specific location in a file |
get_completions |
Get code completion suggestions at a specific location in a file |
get_code_actions |
Get code actions for a specific range in a file |
open_document |
Open a file on the LSP server for analysis |
close_document |
Close a file on the LSP server |
get_diagnostics |
Get diagnostic messages (errors, warnings) for open files |
start_lsp |
Start the LSP server with the specified root directory |
restart_lsp_server |
Restart the LSP server without restarting the MCP server |
set_log_level |
Change the server logging verbosity level at runtime |
Features
- Bridge between LLMs and Language Server Protocol servers
- Real-time diagnostic updates via subscriptions
- Code hover information and code completion suggestions
- Code actions and error handling
- Comprehensive logging system with 8 severity levels
- Runtime-configurable logging level
- Language-specific extensions (Haskell support included)
- Integration tests for TypeScript LSP
- MCP resources for diagnostics, hover, and completions
- Resource subscriptions for real-time updates
Usage Examples
Get hover information for a function at line 3, column 5 in a Haskell file
Get code completion suggestions at a specific position in a file
Get diagnostic errors and warnings for all open files
Get code actions to fix errors in a specific code range
Start the LSP server for a project directory before analyzing code
Resources
Notes
Requires Node.js v16+ and npm. The LSP server must be explicitly started using the start_lsp tool before using other LSP functionality. Supports extensions for language-specific capabilities. Files must be opened with open_document before accessing diagnostics or other file-specific operations.