You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Model Context Protocol (MCP) stdio server that wraps language servers to expose a safe, read-oriented code-intelligence tool surface for coding agents. Supports TypeScript, JavaScript, Python, Go, and Rust — 59 tools across navigation, diagnostics, refactoring, deep understanding, hierarchy, lifecycle, and operations.
# Prerequisites: install language servers
npm install -g typescript-language-server pyright
# Go and Rust: install gopls and rust-analyzer via your package manager# Clone and install
git clone https://github.com/beruang/lsp-mcp.git
cd lsp-mcp
pnpm install
# Build
pnpm run build
# Point at a workspace and start
WORKSPACE_PATH=/path/to/your/project node dist/index.js
Connect any MCP client to the server's stdio transport.
Prerequisites
Dependency
Version
Purpose
Node.js
>= 20
Runtime
pnpm
—
Package management
typescript-language-server
—
TypeScript/JavaScript LSP backend
pyright-langserver
—
Python LSP backend
gopls
—
Go LSP backend
rust-analyzer
—
Rust LSP backend
Language servers must be on $PATH. The server checks availability via lsp_list_supported_languages.
Use lsp_get_config to inspect effective configuration and lsp_update_runtime_config to adjust limits, timeouts, cache TTLs, and debug flags at runtime (in-memory only).
The server is designed for read-oriented coding agents:
Guard
Mechanism
Workspace containment
Every file path validated against WORKSPACE_PATH
No file writes
All tools are read-only; lsp_rename_preview returns a diff but never applies edits
Result caps
All list results are truncated with configurable limits
Timeouts
Every LSP request has a per-method deadline
Structured errors
All errors use the uniform { error: { code, message, details } } envelope
Request log privacy
Logs method, duration, status — never full file contents (unless verbose logging explicitly enabled)
Method denylist
lsp_raw_request blocks workspace/applyEdit, workspace/executeCommand, and other dangerous methods
Restart rate limiting
Max 3 restarts per 60s per language
State machine validation
Invalid LSP state transitions are logged and rejected
Development
pnpm run typecheck # TypeScript type-check
pnpm run lint # ESLint (zero warnings)
pnpm run lint:fix # ESLint auto-fix
pnpm run dev # Run with tsx (no build)
pnpm run build # Build to dist/
pnpm run start # Start built artifact
V1-V3 regression: all passing with every V4 change
Supported Languages
Language
Extensions
Language Server
Language ID
TypeScript
.ts, .tsx
typescript-language-server --stdio
typescript
JavaScript
.js, .jsx
typescript-language-server --stdio
typescript
Python
.py
pyright-langserver --stdio
python
Go
.go
gopls
go
Rust
.rs
rust-analyzer
rust
Adding a language:
Entry in src/config/languageServers.ts
Binary on $PATH
Optional waitConfig in src/lsp/diagnosticsCache.ts
Troubleshooting
lsp_server_unavailable
which typescript-language-server pyright-langserver gopls rust-analyzer
npm install -g typescript-language-server pyright
Use lsp_list_supported_languages to check binary availability at runtime.
path_outside_workspace
Set WORKSPACE_PATH to the project root. Symlinks are resolved before containment check.
No diagnostics
Diagnostics are cached from publishDiagnostics notifications. For cold cache, use lsp_diagnostics with workspaceWide: true to trigger a warm-up pass, or lsp_wait_for_diagnostics.
Stale diagnostics after external edit
Use lsp_sync_document to notify the LSP of changes, then lsp_wait_for_diagnostics. For bulk recovery, lsp_restart_server with reopenDocuments: true.