Quick Start
1
Simple Usage
Pass tool names as strings — the agent resolves them from the built-in registry:
2
Pass Tools Directly
Import the functions and pass them to
Agent:3
Direct Call (No Agent)
Call tools directly without an agent:
How It Works
Each tool call spawns a freshLSPClient, opens the document (didOpen), runs the query, and closes cleanly. There is no shared long-lived server process — every call is self-contained.
Choose the Right Tool
Supported Languages
The language server is chosen automatically from the file extension — you never wire up a server yourself.
The server binary must be on your
PATH; when it is missing the tools return the install hint above instead of failing silently. lsp_workspace_symbols without a file_path defaults to the Python language server.
Zero-config: pick a server automatically
detect_language maps a file to its language by extension, so the correct server is spawned with no setup.
None, and the tools degrade explicitly.
When the server is missing
A missing language server produces an actionable message telling you exactly what to install — never a silent no-op. Check availability before spawning withprobe, which returns (available, command, install_hint):
lsp_* navigation tools embed the hint in their error string:
Monorepos and multi-root workspaces
detect_root_uri walks up from the file to the nearest root marker, so the server initialises against the real project root instead of the current working directory.
Helpers Reference
Import these directly frompraisonaiagents.lsp for zero-config detection and availability checks.
path_to_uri percent-encodes reserved characters (spaces, #), so projects whose paths contain them no longer break — the old failure mode where URIs truncated at those characters is gone.
LSPClient Updates
LSPClient now auto-detects the workspace root and degrades gracefully instead of raising.
workspace_file= so a monorepo file initialises against its own project root:
Addressing: Position or Symbol
Position-taking tools (lsp_definition, lsp_references, lsp_hover) accept two addressing styles:
- Explicit position — pass
lineandcharacteras 0-indexed integers (LSP convention). The output uses 1-indexed numbers so results are human-readable. - Symbol name — pass
symbol="my_func"and the tool locates the first word-boundary occurrence of that name in the file, converting it to a position automatically.
lsp_hover requires an explicit (line, character) — it does not accept a symbol name.
Configuration Options
Python reference for the underlying LSP client
How
Agent(tools=[…]) resolves tool namesCommon Patterns
Investigate a symbol before refactoring Uselsp_definition to find where something is defined, then lsp_references to see every call site before changing anything:
Best Practices
Install the language server when prompted
Install the language server when prompted
Detection is automatic, but the server binary still needs to be on The error names the missing binary and its install command, e.g.
PATH. When one is missing, the tools tell you exactly what to install:Error: go language server `gopls` not installed (install with `go install golang.org/x/tools/gopls@latest`); … — it never raises an exception.Prefer symbol= over line/character when position is unknown
Prefer symbol= over line/character when position is unknown
If you don’t already know the exact line number, pass
symbol="my_func" instead of guessing a position. The tool locates the first word-boundary occurrence for you, so results are always accurate.Narrow workspace-symbol queries
Narrow workspace-symbol queries
lsp_workspace_symbols caps output at 100 results and prints ... (N more; narrow your query) when the cap is hit. Use specific substrings — "parse_config" rather than "parse" — to stay inside the limit.Graceful degradation is by design
Graceful degradation is by design
When a language server is not installed the tools return a clear error string rather than raising. Check the return value for
Error: … not installed and fall back to grep-based tools (ast_grep, shell search) when needed.Paths with spaces or # just work
Paths with spaces or # just work
Files whose paths contain reserved characters (spaces,
#) are handled correctly — path_to_uri percent-encodes them into valid file:// URIs, and results are decoded back on the way in, so no more truncation at those characters.Related
Built-in Tool Registry
How to register and resolve tools with
Agent(tools=[…])LSP Service Command
The
praisonai lsp CLI command for managing the LSP service
