lsp-mcp

lsp-mcp

An MCP server bridging LSP hover and completion for LLM access.

87
Stars
11
Forks
0
Releases

Overview

Provides a bridge between the Model Context Protocol (MCP) and the Language Server Protocol (LSP) to expose LSP capabilities to large language models. The MCP server starts an LSP client that connects to an LSP server, and it exposes MCP tools that translate LSP requests into MCP-friendly operations, returning results in a format that LLMs can easily understand. This enables LLMs to utilize LSP features such as hover information, code completions, and diagnostics to generate more accurate and context-aware suggestions. The repository includes a sample configuration showing how to launch the MCP server via stdio with npx, language identifiers, the path to the LSP, and optional arguments. Key tools include get_info_on_location, get_completions, get_code_actions, open_document, close_document, get_diagnostics, start_lsp, restart_lsp_server, and set_log_level for runtime control. It also offers MCP resources (lsp-diagnostics://, lsp-hover://, lsp-completions://) for real-time updates or point-in-time queries, and supports both tool-based and resource-based access. Additional features cover logging, colorized output, extensions, and a simple CLI.

Details

Owner
Tritlo
Language
TypeScript
License
MIT License
Updated
2025-12-07

Features

get_info_on_location

Gets hover information at a specific location in a file and returns MCP-friendly data.

get_completions

Gets code completion suggestions at a given location in a file.

get_code_actions

Retrieves code actions for a specified range in a file.

open_document

Opens a file in the LSP server for analysis and diagnostics.

close_document

Closes a file in the LSP server to free resources.

get_diagnostics

Retrieves diagnostic messages (errors/warnings) for open files, optionally scoped to a file.

start_lsp

Starts the LSP server with a specified root directory.

restart_lsp_server

Restarts the LSP server process without restarting the MCP server.

Audience

LLM developersIntegrate LSP hover and completion data into LLM prompts and responses via MCP tools and resources.
AI copilots / code assistantsAccess real-time or on-demand LSP data to improve code suggestions and analyses.
LSP-powered tooling developersBuild language-specific extensions and resource handlers to extend MCP capabilities.

Tags

LSPMCPhovercompletionsdiagnosticscode actionsLSP clientNode.jsCLIextensionsHaskell