Skip to content

lsp-client/cli

Repository files navigation

LSP CLI

Python License

A powerful command-line interface for the Language Server Agent Protocol (LSAP). lsp-cli provides a bridge between traditional Language Server Protocol (LSP) servers and high-level agentic workflows, offering structured data access and a robust background server management system.

Built on top of lsp-client and LSAP, this tool is designed for developers and AI agents who need reliable, fast, and structured access to language intelligence.

Key Features

  • 🚀 Instant Analysis: Quickly get definitions, references, hover info, and completions from the terminal.
  • 🏢 Managed Server Lifecycle: A background manager automatically handles language server processes, reusing them across requests for maximum performance.
  • 🧩 LSAP Integration: Leverages the Language Server Agent Protocol for structured, agent-friendly responses with built-in pagination and text-based location finding.
  • ⚡ Async-First: Built with anyio and asyncer for high-performance concurrent operations.
  • 🎨 Rich Output: Beautifully formatted terminal output using rich.

Installation

uv tool install lsp-cli

Quick Start

The main entry point is the lsp command. It automatically detects the appropriate language server for your project.

Find Definition

lsp definition main.py --line 10 --find "my_function"

Get Code Completion

lsp completion src/utils.py --line 5 --find "obj."

Find References

lsp reference models.py --line 20 --find "UserClass"

Search Workspace Symbols

lsp symbol "MyClass" .

Commands

Command Description Alias
definition Find symbol definition, declaration, or type definition def
completion Get code completion suggestions with pagination comp
hover Get hover information (type info, documentation) -
reference Find symbol references or implementations ref
outline Get a structured symbol outline for a file -
symbol Search for symbols across the entire workspace sym
server Manage background LSP server processes -

Server Management

lsp-cli uses a background manager process to keep language servers alive between command invocations. This significantly reduces latency for repeated queries.

# List all running LSP servers
lsp server list

# Manually start a server for a path
lsp server start .

# Stop a server
lsp server stop .

The manager starts automatically when you run any analysis command.

Configuration

lsp-cli can be configured via environment variables or a config.toml file.

  • Config File: ~/.config/lsp-cli/config.toml (on Linux) or ~/Library/Application Support/lsp-cli/config.toml (on macOS).
  • Environment Variables: Prefix with LSP_ (e.g., LSP_LOG_DIR=/tmp/logs).

Contributing

Contributions are welcome! Please see our Contributing Guide for details on:

  • Development setup
  • Adding new CLI commands
  • Improving the server manager
  • Development workflow

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • lsp-client: The underlying LSP client library.
  • LSAP: The Language Server Agent Protocol.
  • lsprotocol: LSP type definitions.

About

CLI interface for the Language Server Agent Protocol (LSAP)

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages