Skip to content

Feature: send workspace/didDeleteFiles and didChangeWatchedFiles notifications #9

Description

@nemekath

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions