Skip to main content
LSP tools give your agent language-server-accurate “go to definition” and “find references” instead of relying on text grep.
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

1

Install

2

Enable LSP navigation tools

3

Use tool names as strings


How It Works


The Five Tools

lsp_definition

Go to the definition of a symbol.

lsp_references

Find all references to a symbol across the codebase.

lsp_hover

Get type, signature, or documentation at an exact position.
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.
Nested symbols (methods inside classes) are flattened and tagged with their parent’s name.

lsp_workspace_symbols

Search for a symbol by name across the entire workspace.

Choosing Between Position and Symbol

  • Explicit positionline and character are 0-indexed (LSP convention). Output shows them 1-indexed so results are human-readable.
  • Symbol namesymbol="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 on PATH. If the server is missing, the tool returns a clear error — it never crashes the agent.
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 the login function?” Agent picks lsp_references("src/auth.py", symbol="login") and calls it. Tool returns:
Agent replies: “The login function is called in 3 places: in user.py at line 45 when handling a user view, in endpoints.py at line 88 inside an API endpoint guard, and in test_auth.py at line 22 in a unit test.”

Common Patterns

Refactor safely: find all references before changing a signature
Explore an unfamiliar file: symbols first, then hover

Best Practices

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.
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.
LSP is more accurate than text search but takes a moment to start. Use ast_grep_tools or shell_tools only when the tool returns an Error: … not installed message.
Results are capped at 100. If you see ... (N more; narrow your query), use a more specific substring — "parse_config" instead of "parse".

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