mcp-lsp-v1
Provides code intelligence tools for JavaScript projects using the TypeScript language server, including navigation, diagnostics, refactoring, and deep understanding.
Provides code intelligence tools for Python projects using the Pyright language server, including navigation, diagnostics, refactoring, and deep understanding.
Provides code intelligence tools for Rust projects using the rust-analyzer language server, including navigation, diagnostics, refactoring, and deep understanding.
Provides code intelligence tools for TypeScript projects using the TypeScript language server, including navigation, diagnostics, refactoring, and deep understanding.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-lsp-v1show hover info for 'validateUser' in src/auth.ts"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP LSP — Code Intelligence Server
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.
Table of Contents
Related MCP server: agent-workspace-mcp
Quick Start
# 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.jsConnect any MCP client to the server's stdio transport.
Prerequisites
Dependency | Version | Purpose |
Node.js | >= 20 | Runtime |
pnpm | — | Package management |
| — | TypeScript/JavaScript LSP backend |
| — | Python LSP backend |
| — | Go LSP backend |
| — | Rust LSP backend |
Language servers must be on $PATH. The server checks availability via lsp_list_supported_languages.
Installation
pnpm installDependencies: @modelcontextprotocol/sdk, vscode-jsonrpc, vscode-languageserver-types, zod, diff.
Configuration
Environment Variables
Variable | Required | Default | Description |
| No |
| Absolute path to the workspace root |
Runtime Config (V4)
Variable | Default | Description |
| 200 | Max references returned |
| 100 | Max workspace symbols |
| 500 | Max diagnostics |
| 50 | Max completion items |
| 100 | Max files in rename preview |
| 1000 | Max edits in workspace edit |
| 20000 | Max context characters |
| 3000 | Hover timeout |
| 5000 | Definition timeout |
| 10000 | References timeout |
| 500 | Request log ring buffer size |
| false | Enable debug raw request tool |
| false | Verbose logging |
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).
Architecture
src/
├── index.ts # Entry point — MCP server bootstrap
├── config/
│ ├── languageServers.ts # Language server registry
│ ├── defaults.ts # Default runtime config values
│ ├── envConfig.ts # Environment variable parsing
│ └── runtimeConfig.ts # In-memory config merge + validation
├── lsp/
│ ├── LspClient.ts # LSP connection: spawn, initialize, request, shutdown
│ ├── LspClientManager.ts # Per-language client pool + state queries
│ ├── LspState.ts # 8-state machine with validated transitions
│ ├── capabilities.ts # Server capabilities extraction
│ ├── diagnosticsCache.ts # publishDiagnostics notification cache
│ ├── documentStore.ts # didOpen/didChange state tracking
│ └── normalize.ts # LSP → normalized shape converters
├── mcp/
│ ├── registerTools.ts # All 59 MCP tool registrations
│ ├── toolErrors.ts # Structured error envelope
│ └── schemas.ts # Zod schemas
├── navigation/ # V3: declaration, typeDef, implementation, signatureHelp, completion
├── hierarchy/ # V3: call hierarchy + type hierarchy (prepare, incoming/outgoing, super/subtypes)
├── workspaceEdit/ # V2: parse, validate, preview workspace edits
├── codeActions/ # V2: code action cache + normalization
├── diagnostics/ # V2: snapshot store, compare, wait-for-diagnostics
├── context/ # V3: enclosing symbol, symbol context, file outline
├── analysis/ # V3: change impact, fix candidates, explain diagnostics
├── formatting/ # V2: format + range format preview
├── refactor/ # V2: prepare rename, organize imports
├── composite/ # V1: diagnostics summary, inspect symbol
├── diff/ # V1: applyTextEdits, workspaceEditToDiff
├── semantic/ # V3: fixDiagnosticCandidates, explainDiagnostics, analyzeChangeImpact
├── documents/ # V4: open, close, sync, save, list documents
├── ops/ # V4: server status, restart, shutdown, readiness, liveness, workspace status
├── observability/ # V4: request tracker, request log
├── cache/ # V4: cache status + selective clearing
├── debug/ # V4: raw request (disabled by default, method denylist)
├── safety/
│ ├── paths.ts # Workspace containment check
│ └── limits.ts # Truncation caps and timeouts
└── utils/
├── asyncTimeout.ts # Promise race with timeout
├── uri.ts # URI ↔ path conversion
├── symbols.ts # Symbol kind normalization
├── ids.ts # ID generation
├── text.ts # Text utilities
└── time.ts # Time utilitiesAPI Reference
Every tool returns either a success payload or a structured error:
{
"error": {
"code": "path_outside_workspace",
"message": "Human-readable description",
"details": {}
}
}Navigation & Discovery
Tool | LSP Method | Description |
|
| Type information and documentation at cursor |
|
| Go-to-definition locations |
|
| Find all references to a symbol |
|
| Symbol outline for a file |
|
| Workspace-wide symbol search |
|
| Go-to-declaration |
|
| Go-to-type-definition |
|
| Find implementations |
Diagnostics
Tool | Description |
| Cached diagnostics for a file or workspace-wide |
| Grouped diagnostics with root-cause heuristic |
| Wait for fresh diagnostics after a change |
| Save a named diagnostic snapshot for comparison |
| Diff two diagnostic snapshots |
| Cluster diagnostics and identify root causes |
| Multi-source fix suggestions (hover + code actions + definition) |
Refactoring & Editing
Tool | LSP Method | Description |
|
| Preview rename via |
|
| Check if rename is valid at a position |
|
| Preview code actions with diffs |
|
| Resolve a cached code action |
|
| Preview formatting with diff |
|
| Preview range formatting with diff |
|
| Preview import organization with diff |
| — | Preview any |
| — | Validate |
Deep Understanding
Tool | LSP Method | Description |
|
| Function signature at call site |
|
| Code completion suggestions |
| composite | Aggregate: hover + definition + refs + risk hints |
| composite | Surrounding symbols at a position |
| composite | Innermost enclosing symbol |
| composite | File-level symbol outline |
Hierarchy & Impact
Tool | LSP Method | Description |
|
| Prepare call hierarchy for a symbol |
|
| Who calls this symbol |
|
| What this symbol calls |
|
| Prepare type hierarchy |
|
| Super-types of a symbol |
|
| Sub-types of a symbol |
| composite | Cross-file impact analysis for a proposed change |
Server Lifecycle
Tool | Description |
| Runtime status for all configured language servers |
| Restart a language server (reopens docs, clears diagnostics) |
| Graceful shutdown with timeout |
| Configured languages, extensions, commands, binary availability |
| Normalized LSP capabilities per language |
Document Lifecycle
Tool | LSP Method | Description |
|
| Register a document with the LSP server |
|
| Unregister a document |
|
| Notify LSP of content changes |
|
| Notify LSP of a save |
| — | All currently tracked open documents |
Health
Tool | Description |
| Server health and per-language LSP capabilities |
| Workspace + language server availability check |
| Fast liveness check + optional memory stats |
Observability & Cache
Tool | Description |
| LSP request history with filtering |
| Clear request log entries |
| Entry counts for all internal caches |
| Selective or full cache clearing |
Configuration
Tool | Description |
| Effective config (defaults → env → runtime overrides) |
| In-memory config updates (limits, timeouts, caches, debug) |
Debug
Tool | Description |
| Raw LSP request with method denylist (disabled by default) |
Multi-Workspace
Tool | Description |
| Known workspaces (foundation) |
| Status for a specific workspace (foundation) |
Error Handling
Every tool returns errors in a uniform envelope:
{
"error": {
"code": "path_outside_workspace",
"message": "Path is outside workspace: /etc/passwd",
"details": {}
}
}Error Codes
Code | Trigger |
|
|
| File extension has no registered LSP server |
| File does not exist on disk |
| Language server binary not on |
| Server not initialized |
| LSP request returned an error |
| LSP request exceeded its deadline |
| Server does not support the capability |
| Server lacks declaration provider |
| Server lacks type definition provider |
| Server lacks implementation provider |
| Server lacks signature help provider |
| Server lacks completion provider |
| Server lacks call hierarchy provider |
| Hierarchy item ID not found |
| Hierarchy item TTL expired |
| Server lacks type hierarchy provider |
| Type hierarchy item ID not found |
| Type hierarchy item TTL expired |
| Change impact partial results |
| Diagnostic index not found |
| Unknown config key in update |
| Invalid config value (e.g., negative limit) |
| Attempt to change workspacePath at runtime |
| Language not configured |
| Too many restarts in window |
| Debug tool is disabled |
| LSP method blocked by denylist |
| Document not in open documents store |
Safety Model
The server is designed for read-oriented coding agents:
Guard | Mechanism |
Workspace containment | Every file path validated against |
No file writes | All tools are read-only; |
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 |
Request log privacy | Logs method, duration, status — never full file contents (unless verbose logging explicitly enabled) |
Method denylist |
|
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 artifactPre-commit Hook
husky + lint-staged:
eslint --fix --max-warnings 0pnpm run typecheckpnpm run verify:decoupling
Conventions
Module system: ESM (
"type": "module",NodeNext)TypeScript: strict, target ES2022
Testing:
node --test+tsxLinting: ESLint with
@typescript-eslint, zero-warnings policy
Testing
pnpm test # All unit tests
npm run test:safety # Safety tests
npm run test:integration # Integration tests (requires language servers)Coverage
106+ tests across unit, integration, and safety suites
5 languages: TypeScript, JavaScript, Python, Go, Rust
V1-V3 regression: all passing with every V4 change
Supported Languages
Language | Extensions | Language Server | Language ID |
TypeScript |
|
|
|
JavaScript |
|
|
|
Python |
|
|
|
Go |
|
|
|
Rust |
|
|
|
Adding a language:
Entry in
src/config/languageServers.tsBinary on
$PATHOptional
waitConfiginsrc/lsp/diagnosticsCache.ts
Troubleshooting
lsp_server_unavailable
which typescript-language-server pyright-langserver gopls rust-analyzer
npm install -g typescript-language-server pyrightUse 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.
Changelog
Version | Focus | Key Additions |
V4 | Production operations | Server lifecycle, document lifecycle, observability, cache, config, health, debug, multi-workspace (21 tools) |
V3 | Deep understanding | Hierarchy (call + type), declaration, type definition, implementation, signature help, completion, impact analysis (17 tools) |
V2 | Safe refactoring | Preview-first editing — rename, code actions, formatting, organize imports, diagnostics snapshots (11 tools) |
V1 | Semantic navigation | Hover, definition, references, symbols, diagnostics, rename preview, inspect (10 tools) |
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/beruang/lsp-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server