Skip to content

feat(mcp): add LSP 3.17 tools and MCP resources for diagnostics#124

Merged
bug-ops merged 4 commits into
mainfrom
lsp317-tools-mcp-resources
Apr 29, 2026
Merged

feat(mcp): add LSP 3.17 tools and MCP resources for diagnostics#124
bug-ops merged 4 commits into
mainfrom
lsp317-tools-mcp-resources

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Apr 29, 2026

Summary

Implements two features together:

Issue #116 — 4 new LSP tools:

  • get_signature_helptextDocument/signatureHelp (LSP 3.15): method parameter hints at call-site position
  • go_to_implementationtextDocument/implementation (LSP 3.6): navigate from trait/interface to concrete implementations
  • go_to_type_definitiontextDocument/typeDefinition (LSP 3.6): navigate to the type definition of an expression
  • get_inlay_hintstextDocument/inlayHint (LSP 3.17): inline type annotations over a range

All tools follow the existing 1-based MCP position convention and degrade gracefully when the LSP server lacks the capability.

Issue #115 — MCP resources for diagnostics:

  • resources/list returns lsp-diagnostics:/// URIs for open documents
  • resources/read returns cached diagnostics as JSON
  • resources/subscribe / unsubscribe register interest in push updates
  • Split-phase diagnostics_pump: starts before MCP serve to avoid dropping first-paint diagnostics, fires notify_resource_updated for subscribed URIs once peer is captured
  • RFC 3986-conformant URI codec via url::Url::from_file_path with percent-encoding
  • Workspace-root containment enforced in both read_resource and subscribe via validate_path
  • Subscription set capped at 1 000 entries

Refactoring (post-rebase cleanup):

  • Remove spawn_batch_with_notifications (superseded by LspServer.notification_rx added in main)
  • Add LspServer::take_notification_rx to extract receiver before server registration
  • Handle LspNotification::Progress variant in diagnostics_pump

Test plan

  • cargo +nightly fmt --all -- --check passes
  • cargo clippy --all-targets --all-features --workspace -- -D warnings passes
  • cargo nextest run --workspace --all-features --lib --bins — 380/380 tests pass
  • RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features passes
  • New tools visible in MCP tool list (manual verification with an MCP client)
  • resources/list returns URIs for open documents
  • Subscribing to a diagnostics resource and receiving push notifications

Closes #116, Closes #115

bug-ops added 2 commits April 29, 2026 18:53
…#115)

Issue #116 — add four missing LSP tools:
- get_signature_help: textDocument/signatureHelp (LSP 3.15)
- go_to_implementation: textDocument/implementation (LSP 3.6)
- go_to_type_definition: textDocument/typeDefinition (LSP 3.6)
- get_inlay_hints: textDocument/inlayHint (LSP 3.17)

All tools follow the existing 1-based MCP position convention and degrade
gracefully when the LSP server does not support the capability.

Issue #115 — expose LSP diagnostics as subscribable MCP resources:
- resources/list returns lsp-diagnostics:/// URIs for open documents
- resources/read returns cached diagnostics as JSON
- resources/subscribe / unsubscribe register interest in push updates
- Split-phase diagnostics_pump caches PublishDiagnostics before the MCP
  peer is captured, then fires notify_resource_updated for subscribed URIs

URI codec (bridge::resources) uses url::Url::from_file_path for
RFC 3986-conformant percent-encoding. Subscription set is capped at 1 000
entries. Workspace-root containment is enforced in both read_resource and
subscribe via validate_path.

Closes #116, Closes #115
Remove spawn_batch_with_notifications and spawn_with_notifications (no
longer needed now that LspServer carries notification_rx directly).

Add LspServer::take_notification_rx to extract the receiver before
registering the server with the translator, replacing it with a dummy
channel so the struct remains fully initialized.

Extract register_servers helper to keep serve() within the 100-line
clippy limit.

Handle LspNotification::Progress variant added in main to fix the
non-exhaustive match in diagnostics_pump.
@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes mcpls-core mcpls-core crate changes labels Apr 29, 2026
@bug-ops bug-ops enabled auto-merge (squash) April 29, 2026 16:59
@github-actions github-actions Bot added the testing Test-related changes label Apr 29, 2026
@bug-ops bug-ops merged commit 87166fc into main Apr 29, 2026
27 checks passed
@bug-ops bug-ops deleted the lsp317-tools-mcp-resources branch April 29, 2026 17:17
bug-ops added a commit that referenced this pull request Apr 29, 2026
Add 7 sub-cases to ra_e2e_suite:
- sc_get_signature_help, sc_go_to_implementation, sc_go_to_type_definition,
  sc_get_inlay_hints — cover the 4 tools added in #124 that had no e2e
  coverage against real rust-analyzer
- sc_list_resources, sc_read_resource, sc_subscribe_unsubscribe_resource —
  cover the MCP resources path (list/read/subscribe/unsubscribe) end-to-end

Add list_resources, read_resource, subscribe_resource, unsubscribe_resource
to McpClient test helper. Add lib_rs_uri() helper that derives the
lsp-diagnostics:// URI from the live resources/list response to avoid
path-encoding drift on macOS canonicalised paths.

Append lsp317_target() to the rust_workspace fixture as a stable anchor
for the new sub-cases (append-only, no existing anchors disturbed).

Closes #129, closes #130
bug-ops added a commit that referenced this pull request May 1, 2026
…#139)

Add 7 sub-cases to ra_e2e_suite:
- sc_get_signature_help, sc_go_to_implementation, sc_go_to_type_definition,
  sc_get_inlay_hints — cover the 4 tools added in #124 that had no e2e
  coverage against real rust-analyzer
- sc_list_resources, sc_read_resource, sc_subscribe_unsubscribe_resource —
  cover the MCP resources path (list/read/subscribe/unsubscribe) end-to-end

Add list_resources, read_resource, subscribe_resource, unsubscribe_resource
to McpClient test helper. Add lib_rs_uri() helper that derives the
lsp-diagnostics:// URI from the live resources/list response to avoid
path-encoding drift on macOS canonicalised paths.

Append lsp317_target() to the rust_workspace fixture as a stable anchor
for the new sub-cases (append-only, no existing anchors disturbed).

Closes #129, closes #130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation mcpls-core mcpls-core crate changes rust Rust code changes testing Test-related changes

Projects

None yet

1 participant