Prerequisites
- Python 3.10 or higher
- PraisonAI Agents package installed (
pip install praisonaiagents) - A language server binary on
PATH(see Language Server Installation)
Quick Start
How It Works
| Step | What happens |
|---|---|
| Agent receives request | Agent picks the correct LSP tool based on the question |
| Tool prepares | Resolves path inside workspace, detects language from extension |
| Language server query | LSP client spawns server (if needed), sends JSON-RPC request |
| Result returned | Compact file:line:col snippet string — no raw JSON |
The Five Tools
lsp_definition
Go to the definition of a symbol.| Parameter | Type | Default | Description |
|---|---|---|---|
file_path | str | required | File to query (workspace-relative or absolute) |
line | Optional[int] | None | 0-indexed line. Optional when symbol is given |
character | Optional[int] | None | 0-indexed column. Optional |
symbol | Optional[str] | None | Symbol name; first word-boundary occurrence is used |
lsp_references
Find all references to a symbol across the codebase.| Parameter | Type | Default | Description |
|---|---|---|---|
file_path | str | required | File to query |
line | Optional[int] | None | 0-indexed line |
character | Optional[int] | None | 0-indexed column |
symbol | Optional[str] | None | Symbol name |
include_declaration | bool | True | Include the declaration itself in results |
lsp_hover
Get type, signature, or documentation at an exact position.| Parameter | Type | Default | Description |
|---|---|---|---|
file_path | str | required | File to query |
line | int | required | 0-indexed line (LSP convention) |
character | int | required | 0-indexed column |
lsp_hover requires exact (line, character) — it does not accept a symbol name. Use lsp_document_symbols first to find the position.lsp_document_symbols
List every symbol defined in a file — classes, functions, methods, variables.| Parameter | Type | Default | Description |
|---|---|---|---|
file_path | str | required | File to query |
lsp_workspace_symbols
Search for a symbol by name across the entire workspace.| Parameter | Type | Default | Description |
|---|---|---|---|
query | str | required | Symbol name or substring to search for |
file_path | Optional[str] | None | Hint which language server to use; defaults to Python |
Choosing Between Position and Symbol
- Explicit position —
lineandcharacterare 0-indexed (LSP convention). Output shows them 1-indexed so results are human-readable. - Symbol name —
symbol="my_func"finds the first word-boundary occurrence in the file automatically. Recommended when you don’t know the exact column.
Language Server Installation
Each supported language needs its server binary onPATH. If the server is missing, the tool returns a clear error — it never crashes the agent.
| Language | Extensions | Install command |
|---|---|---|
| Python | .py, .pyi | pip install python-lsp-server |
| JavaScript | .js, .jsx, .mjs, .cjs | npm install -g typescript-language-server typescript |
| TypeScript | .ts, .tsx | npm install -g typescript-language-server typescript |
| Rust | .rs | rustup component add rust-analyzer |
| Go | .go | go install golang.org/x/tools/gopls@latest |
When the server is missing, the tool returns
Error: python language server not installed; install it to use lsp navigation (falling back to grep is advised) — the agent keeps running and can fall back to other search tools.User Interaction Flow
A typical agent session using LSP tools:User: “Who calls theloginfunction?” Agent pickslsp_references("src/auth.py", symbol="login")and calls it. Tool returns:Agent replies: “Theloginfunction is called in 3 places: inuser.pyat line 45 when handling a user view, inendpoints.pyat line 88 inside an API endpoint guard, and intest_auth.pyat line 22 in a unit test.”
Common Patterns
Refactor safely: find all references before changing a signatureBest Practices
Prefer symbol= over hard-coded (line, character)
Prefer symbol= over hard-coded (line, character)
The LLM rarely knows exact column numbers. Pass
symbol="my_func" instead — the tool locates the first word-boundary occurrence and converts it to a position automatically.Combine lsp_references with lsp_definition for full context
Combine lsp_references with lsp_definition for full context
Before editing anything, use
lsp_definition to find where it’s defined, then lsp_references to see every call site. This prevents breaking callers you didn’t know existed.Keep workspace-symbol queries narrow
Keep workspace-symbol queries narrow
Results are capped at 100. If you see
... (N more; narrow your query), use a more specific substring — "parse_config" instead of "parse".Related
AST-Grep Tools
Structural code search and rewrite with AST patterns
Shell Tools
Execute shell commands and system operations
File Tools
File system read, write, and search operations
LSP Navigation (Feature)
Deep dive into how LSP navigation works

