Problem
After a file is deleted or renamed in the workspace, the LSP server retains
stale diagnostics for the removed file. workspace_diagnostics continues to
report errors from files that no longer exist.
Root cause
The lsp-mcp-server adapter bridges MCP tool calls to LSP requests but does not
send workspace/didDeleteFiles or workspace/didChangeWatchedFiles
notifications to the language server. The LSP spec defines these notifications
specifically so servers can invalidate their caches.
Current workaround
Call lsp_index_files again after any file creation, deletion, or rename.
This forces a re-scan but is manual and easy to forget.
Suggested fix
Option A (minimal): After lsp_index_files is called, diff the current file
list against the previous one and send workspace/didDeleteFiles for removals.
Option B (complete): Add an fs.watch / chokidar file watcher that sends
workspace/didChangeWatchedFiles notifications automatically when files in
the workspace root change.
Measured impact
Tested with csharp-ls 0.26.0 on a .NET 8 solution (93 test files, 1731 tests).
After deleting a probe file with 3 intentional errors, workspace_diagnostics
continued to report CS0029, CS1061, CS8602 for the deleted file until the
server was restarted.
Environment
- lsp-mcp-server 1.1.20
- csharp-ls 0.26.0
- Windows 11, Node.js 22.21.0
Problem
After a file is deleted or renamed in the workspace, the LSP server retains
stale diagnostics for the removed file.
workspace_diagnosticscontinues toreport errors from files that no longer exist.
Root cause
The lsp-mcp-server adapter bridges MCP tool calls to LSP requests but does not
send
workspace/didDeleteFilesorworkspace/didChangeWatchedFilesnotifications to the language server. The LSP spec defines these notifications
specifically so servers can invalidate their caches.
Current workaround
Call
lsp_index_filesagain after any file creation, deletion, or rename.This forces a re-scan but is manual and easy to forget.
Suggested fix
Option A (minimal): After
lsp_index_filesis called, diff the current filelist against the previous one and send
workspace/didDeleteFilesfor removals.Option B (complete): Add an fs.watch / chokidar file watcher that sends
workspace/didChangeWatchedFilesnotifications automatically when files inthe workspace root change.
Measured impact
Tested with csharp-ls 0.26.0 on a .NET 8 solution (93 test files, 1731 tests).
After deleting a probe file with 3 intentional errors,
workspace_diagnosticscontinued to report CS0029, CS1061, CS8602 for the deleted file until the
server was restarted.
Environment