LSP (Language Server Protocol)

LSP is the standard protocol behind go-to-definition, find-references, diagnostics, and rename. With grep, an agent guesses where a symbol is used. With LSP, it knows.
Why LSP matters for AI
| Capability | Benefit |
|---|---|
| Precise navigation | Knows where foo is defined across files |
| Type information | Knows user.name is a string |
| Semantic understanding | Tells a call from a declaration from a string |
| Real-time diagnostics | Errors without running code |
| Refactoring | Knows every place to change |
LSP vs text search
| Operation | grep | LSP |
|---|---|---|
| Find definition | Text matches | The actual definition |
| Find references | Matches everywhere | Only real usages |
| Rename | Breaks strings and comments | Only the symbol |
| Type info | None | Full signatures |
| Dead code | Can't tell | Flags it |
LSP features in Claude Code
Go to definition, find references, hover info, document and workspace symbols, call hierarchy, and diagnostics after edits.
Common language servers
| Language | Server | Install |
|---|---|---|
| TS/JS | typescript-language-server | bun add -g typescript-language-server typescript |
| Python | Pyright | pip install pyright |
| Go | gopls | go install golang.org/x/tools/gopls@latest |
| Rust | rust-analyzer | rustup component add rust-analyzer |
| Ruby | Ruby LSP | gem install ruby-lsp |
| Java | Eclipse JDT LS | Via IDE or standalone |
| C/C++ | clangd | brew install llvm |
Where it pays off: large refactors in large codebases. Wire LSP into agent tooling first for the languages with the most code and the most churn, and pin server versions in the repo so humans and agents see the same diagnostics.
Where it doesn't: dynamic code (reflection, metaprogramming, string-built calls) hides references from LSP too. Verify wide renames with tests.
With MCP, LSP, and a strong model, agents can change large codebases safely.