Skip to main content
The LSP tool connects your agent to any Language Server Protocol (LSP) server, providing comprehensive code intelligence: go-to-definition, find references, diagnostics, symbol search, renaming, formatting, and more.
The Language Server Protocol is a standard for editor-agnostic language features. Most programming languages have LSP servers available.

Available tools

ToolDescriptionRead-only
lsp_workspaceGet workspace info and available capabilitiesYes
lsp_hoverGet type info and documentation for a symbolYes
lsp_definitionFind where a symbol is definedYes
lsp_referencesFind all references to a symbolYes
lsp_document_symbolsList all symbols in a fileYes
lsp_workspace_symbolsSearch symbols across the workspaceYes
lsp_diagnosticsGet errors and warnings for a fileYes
lsp_code_actionsGet available quick fixes and refactoringsYes
lsp_call_hierarchyFind incoming and outgoing callsYes
lsp_type_hierarchyFind supertypes and subtypesYes
lsp_implementationsFind implementations of an interfaceYes
lsp_signature_helpGet function signature at a call siteYes
lsp_inlay_hintsGet type annotations and parameter namesYes
lsp_renameRename a symbol across the workspaceNo
lsp_formatFormat a fileNo

Configuration

toolsets:
  - type: lsp
    command: gopls
    file_types: [".go"]

Options

command
string
required
The LSP server executable. Must be available in PATH or installed via the version property.
args
array
Command-line arguments passed to the LSP server process.
env
object
Environment variables for the LSP server process.
file_types
array
File extensions this LSP handles (e.g. [".go", ".mod"]). Used to route file requests to the correct server when multiple LSP servers are configured.
version
string
Package reference for auto-installing the LSP server if it is not found in PATH. See Auto-installing tools.

Common LSP servers

toolsets:
  - type: lsp
    command: gopls
    version: "golang/[email protected]"  # optional: auto-install
    file_types: [".go"]

Multiple LSP servers

Configure multiple LSP servers for polyglot codebases:
agent.yaml
agents:
  polyglot:
    model: anthropic/claude-sonnet-4-0
    description: Full-stack developer
    instruction: You are a full-stack developer.
    toolsets:
      - type: lsp
        command: gopls
        file_types: [".go"]
      - type: lsp
        command: typescript-language-server
        args: ["--stdio"]
        file_types: [".ts", ".tsx", ".js", ".jsx"]
      - type: lsp
        command: pylsp
        file_types: [".py"]
      - type: filesystem
      - type: shell

Example agent

agent.yaml
agents:
  developer:
    model: anthropic/claude-sonnet-4-0
    description: Go developer with code intelligence
    instruction: |
      You are a software developer. Use LSP tools for navigation and
      diagnostics. Always check lsp_diagnostics after editing code.
    toolsets:
      - type: lsp
        command: gopls
        file_types: [".go", ".mod"]
      - type: filesystem
      - type: shell

Position format

All LSP tools use 1-based line and character positions:
  • Line 1 is the first line of the file.
  • Character 1 is the first character on the line.
{
  "file": "/path/to/file.go",
  "line": 42,
  "character": 15
}
The LSP tool includes built-in instructions that guide the agent to:
  1. Start with lsp_workspace to discover available capabilities.
  2. Use lsp_workspace_symbols to find relevant code.
  3. Use lsp_references before modifying any symbol.
  4. Check lsp_diagnostics after every code change.
  5. Apply lsp_format after edits are complete.
Always include the filesystem tool alongside LSP. The agent needs filesystem access to read and write files; LSP provides intelligence about the code structure.

Auto-installation

Docker Agent can automatically download and install LSP servers if they are not found in PATH. Set the version property to a package reference, or let Docker Agent auto-detect it from the command name. See Auto-installing tools for details.

Filesystem

Read and write code files alongside LSP.

Shell

Run build and test commands.

Tool configuration

Auto-installing tools and full toolset options.

Think

Plan refactors before executing them.

Build docs developers (and LLMs) love