Skip to content

feat(lsp): implement Phase 2 LSP Client - #7

Merged
bug-ops merged 3 commits into
mainfrom
feature/phase-2-lsp-client
Dec 24, 2025
Merged

feat(lsp): implement Phase 2 LSP Client#7
bug-ops merged 3 commits into
mainfrom
feature/phase-2-lsp-client

Conversation

@bug-ops

@bug-ops bug-ops commented Dec 24, 2025

Copy link
Copy Markdown
Owner

Summary

Complete LSP client implementation with JSON-RPC 2.0 transport layer, enabling communication with language servers.

Components Implemented

  • Transport Layer (lsp/transport.rs)

    • Header-content message format parsing (Content-Length)
    • Async stdio communication with BufReader/BufWriter
    • Message framing and buffering
  • LSP Client Core (lsp/client.rs)

    • Concurrent request handling with tokio channels
    • Atomic request ID generation
    • Background message loop with tokio::select!
    • Timeout support for all requests
  • Lifecycle Management (lsp/lifecycle.rs)

    • Server spawning with tokio::process
    • Initialize/initialized handshake
    • Capability negotiation (position encoding)
    • Graceful shutdown sequence
  • JSON-RPC Types (lsp/types.rs)

    • Request, Response, Notification types
    • RequestId enum (Number/String)
    • Proper serde serialization
  • Position Encoding (bridge/encoding.rs)

    • MCP (1-based) ↔ LSP (0-based) conversion
    • UTF-8/UTF-16/UTF-32 encoding support
    • Multibyte character handling (emoji, CJK)

Quality Reviews

Review Status Details
Performance ✅ APPROVED Grade B+, excellent async patterns
Security ✅ APPROVED LOW risk, no unsafe code
Testing ✅ APPROVED 25 tests passing
Code Review ✅ APPROVED No blocking issues

Test Plan

  • All 25 unit tests pass (cargo test)
  • No clippy errors (cargo clippy)
  • Code compiles on stable Rust
  • Position encoding roundtrip tests
  • JSON-RPC serialization tests

Changes

  • 8 files changed, 1072 insertions(+), 87 deletions(-)
  • New file: crates/mcpls-core/src/lsp/types.rs

Next Steps

After merge, Phase 3 (Document State Management) will implement:

  • Document tracking with didOpen/didChange/didClose
  • Version management
  • LSP synchronization

Complete LSP client implementation with JSON-RPC 2.0 transport:

Transport Layer:
- Header-content message format parsing (Content-Length)
- Async stdio communication with BufReader/BufWriter
- Message framing and buffering

LSP Client Core:
- Concurrent request handling with tokio channels
- Atomic request ID generation
- Background message loop with tokio::select!
- Timeout support for all requests
- Pending request tracking

Lifecycle Management:
- Server spawning with tokio::process
- Initialize/initialized handshake
- Capability negotiation (position encoding)
- Graceful shutdown sequence

Position Encoding:
- MCP (1-based) <-> LSP (0-based) conversion
- UTF-8/UTF-16/UTF-32 encoding support
- Multibyte character handling (emoji, CJK)

Testing:
- 25 tests passing (22 unit + 3 CLI)
- Position encoding: 95% coverage
- JSON-RPC types: 80% coverage

Quality Reviews:
- Performance: APPROVED (Grade B+)
- Security: APPROVED (LOW risk)
- Testing: APPROVED
- Code Review: APPROVED
- Add const fn where applicable (encoding, translator, lifecycle, tools)
- Use inline format arguments for cleaner code
- Add allow attributes for dead_code on unused items (will be used later)
- Add allow attributes for unwrap_used in test modules
- Fix expect_used warning with explicit allow attribute
- Fix needless_pass_by_value for logging init function
- Fix doc_markdown warning for environment variable
Replace rustsec/audit-check@v2 with cargo-deny for more reliable
and comprehensive dependency checks (advisories, licenses, bans, sources).

Add deny.toml configuration with RUSTSEC-2024-0436 ignored
(paste crate unmaintained - transitive dependency from rmcp).
@bug-ops
bug-ops merged commit 22b204a into main Dec 24, 2025
14 checks passed
@bug-ops
bug-ops deleted the feature/phase-2-lsp-client branch December 24, 2025 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant