一个模型上下文协议 (MCP) 服务器,为 LLM/AI 代理提供语言服务器协议 (LSP) 服务器的功能。这使得 AI 具有
LSP MCP
An Model Context Protocol (MCP) server that provides LLMs/AI Agents with the capabilities of a language server protocol (LSP) server. This gives the AI the ability to get language aware context from the codebase.
Use lsp to give me insights into the following typescript code:
let foo = "bar";
function x() {
let foo = 123;
console.log(foo);
}
x();
console.log(foo);
Output:
…
Warning
This is in a POC state.
Features
Multiple LSPs (Multiple programming language support) at the same time, see sample config
Dynamically generates supported LSP method from LSP JSON Schema, see json schema
Quick Start
Claude Desktop
Using Docker (Recommended)
Modify claude_desktop_config.json (As described in the MCP Docs) with the following:
You'll likely want to share some files with the container by passing docker -v /local_dir:/remote_dir. Then you can ask Claude about the files in /remote_dir/.
Using npx
Note: Claude Desktop is finicky with npx it seems. Sometimes it says the mcp fails but the tools still work. I'll look into this... later
This will provide Claude with the LSP capabilities of the typescript language server. You can modify the language server by switching the --lsp argument (and then restarting Claude).
Multiple LSPs at the same time is not yet supported.
Follow the instructions provided by Cursor. For settings, choose Type = command and Command = docker run ... as mentioned above for claude (eg docker run -i --rm -v : jonrad/lsp-mcp:)
yarn
yarn mcp-cli # Interactive MCP tool to help with development
yarn dev --help# Get the CLI help
Dependencies
Decisions
Using python - I want to leverage a client library that makes the startup of this simple. A lot of LSPs are created in node, but the mature client libraries seem to be dependent on vscode. I like the look of multilspy, so we'll start with python. It helps that I already created a python MCP, so at least I'll have a leg up there
uv for package management and such - I've been seeing this used more frequently lately and this is an excuse to learn it. Switching package managers in the future is annoying but doable. I may have to revisit this decision once implementing CI/CD. Maybe I can use this instead of a dependency on taskfile as well? TBD
Async when possible - It's 2025
Switching to node after all. POC with python was more successful than I expected. But, multilspy doesn't support the entire LSP spec and vscode's library will be easier to work with as node is arguably the defacto standard language of LSP servers/clients.
Using the low-level MCP SDK. I think I'll need more control and it's frankly not that complicated as compared to the higher level FastMCP.
Using zod for config validation. It's already a dependency for the MCP SDK, so no reason to overthink it.
I've set to always use an LSP even for unknown languages (eg LLM provides a textDocument/documentSymbol request for python but there is no python LSP registered). I'll probably revisit this decision.
Decided to make the LSPs start only when they are asked something. May make configurable later, but for now this prevents overuse of resources.
Roadmap
This is just a list of things I'd like to do eventually. There is no timeline or order for these.
Figure out how to sync capabilities between the LSP client (this) and the LSP server
Auto generated the LSP JSON Schema or find where it's published
Make json schema a cli argument so we don't have the update code to support new ones
Connect to an already running LSP server (via a multiplexing LSP server?)