Skip to main content
Give your agent language-server-accurate go-to-definition, find-references, and symbol search that works out of the box — the right server is picked from the file extension, and a missing server degrades to an actionable install hint instead of a silent no-op.

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 fresh LSPClient, 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.
Unsupported extensions return 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 with probe, which returns (available, command, install_hint):
The five lsp_* navigation tools embed the hint in their error string:
Post-edit diagnostics surface a one-time-per-language note when a known server is absent:

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.
Nested-project workspace-symbol searches now return results from the file’s own project, not the outer repo.

Helpers Reference

Import these directly from praisonaiagents.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.
Pass 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 line and character as 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 names

Common Patterns

Investigate a symbol before refactoring Use lsp_definition to find where something is defined, then lsp_references to see every call site before changing anything:
Explore an unfamiliar file List what a file exports, then hover over interesting names to understand their signatures:
Locate a function whose name you half-remember Search the whole workspace with a partial name:

Best Practices

Detection is automatic, but the server binary still needs to be on PATH. When one is missing, the tools tell you exactly what to install:
The error names the missing binary and its install command, e.g. Error: go language server `gopls` not installed (install with `go install golang.org/x/tools/gopls@latest`); … — it never raises an exception.
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.
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.
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.
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.

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