Add "headless" mode
Adds "headless" mode, allowing the MCP to talk to an already-running LSP, such as one running in your IDE. Does not set up file watchers in this mode (handled better by the IDE's LSP integration), which has the nice bonus of working around the "too many open files" bug in very large repos.
Integration tests updated for Go, which is the only one I can reliably test on my machine.
Instructions
- Add the necessary arguments to
Goplsto tell it to listen over http. For example, in VSCode / Cursor in.vscode/settings.json:
...(snip)...
"go.useLanguageServer": true,
"go.languageServerFlags": [
"-remote=localhost:6061"
],
...(snip)...
- Launch
mcp-language-serverwith the new arg--lsp-connect=localhost:6061(using whatever hostname:port combo you used to start your Gopls session)
Benefits
In headless mode, the Gopls server that's already running in your IDE can also be used to power the MCP, instead of starting another one in parallel. This can simplify your setup: If you've configured the language server to your liking in your IDE, then your MCP will be sure to use the same LSP as you use in your IDE.
In VSCode / Cursos, you may want to ignore some folders to get better performance for your LSP:
"gopls": {
"build.directoryFilters": [
// this speeds up Go static analysis significantly
// add/remove the stuff you do/don't care about
"-",
"-**/node_modules",
...snip...
When you connect to your already-running LSP, you get the same settings applied in your MCP-LSP session, and can benefit from speedups like directory ignore filters.
Testing
Integrations tests for Go were updated to run in both headless and regular mode. Other languages each require different approaches to getting LSPs running in the background, which may be worth the effort if folks using those languages could add their implementations.
I had to update the snapshot files for the Go integration tests, but this might be due to Go version mismatches. I'm happy to revert those files if it makes this easier to merge; I just wanted to get it all running locally so I could make sure I updated the tests properly.
I also tested in a separate project that previously was hitting the "too many open files" bug; it works around that bug and now the MCP server works great! I have Claude / Cursor using the LSP for renaming and it seems to work quite well!
Can this be merged soon? This way we can avoid having multiple clangd processes running with identical settings fighting over the .cache/clangd directory
I'd like to see this merged too!