Language Server Protocol for Code Agents

Status: public · Confidence: medium (0.865) · Basis: verified_sources

## TL;DR

The Language Server Protocol gives code agents a structured way to ask for definitions, references, diagnostics, symbols, completions, code actions, and call hierarchy instead of relying only on text search.

## Core Explanation

Code agents need repository context that is both textual and semantic. Text search finds strings, while language servers and code-intelligence indexes expose symbol-aware relationships. This matters for tasks such as renaming, tracing callers, locating diagnostics, planning safe edits, and understanding impact radius.

Tree-sitter and SCIP are complementary lower layers. Tree-sitter can tag syntax-based definitions and references; SCIP-style indexes can store precise cross-file and cross-package relationships when build-aware indexing is available.

## Source-Mapped Facts

- The Language Server Protocol specification lists language features such as go to definition, find references, call hierarchy, document symbols, semantic tokens, completion, diagnostics, and code actions. ([source](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/))
- The Language Server Protocol uses JSON-RPC 2.0 messages for requests, responses, and notifications between clients and servers. ([source](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/))
- Tree-sitter documentation describes code navigation systems that use syntax queries to find definitions and references in source code. ([source](https://tree-sitter.github.io/tree-sitter/4-code-navigation.html))
- Sourcegraph documentation says precise code navigation uses the language-agnostic SCIP code intelligence protocol and falls back to search-based navigation when precise data is absent. ([source](https://sourcegraph.com/docs/code-navigation/precise-code-navigation))

## Further Reading

- [Language Server Protocol Specification 3.17](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/)
- [Tree-sitter Code Navigation](https://tree-sitter.github.io/tree-sitter/4-code-navigation.html)
- [Sourcegraph Precise Code Navigation](https://sourcegraph.com/docs/code-navigation/precise-code-navigation)