Add your description here
Project description
LSP CLI
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
anyioandasyncerfor 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
Find where a symbol is defined:
# Using line scope
lsp definition main.py --scope 10
# Using text search to locate the symbol
lsp definition main.py --find "my_function<HERE>"
# Find declaration instead of definition
lsp def models.py --scope 25 --decl
Get Symbol Information
Get detailed information about a symbol at a specific location:
# Get symbol info at line 15
lsp symbol main.py --scope 15
# Find and get symbol info
lsp sym utils.py --find "UserClass<HERE>"
Find References
Find all references to a symbol:
# Find references to a symbol at line 20
lsp reference models.py --scope 20
# Find references with text search
lsp ref models.py --find "UserClass<HERE>"
# Show more context lines around each reference
lsp reference app.py --scope 10 --context-lines 5
# Find implementations instead of references
lsp reference interface.py --scope 15 --impl
Search Workspace Symbols
Search for symbols across the entire workspace by name:
# Search for symbols containing "MyClass"
lsp search MyClass
# Search in a specific workspace
lsp search "UserModel" --workspace /path/to/project
# Filter by symbol kind
lsp search "test" --kind function --kind method
# Limit results
lsp search "Config" --max-items 10
Get File Outline
Get a hierarchical outline of symbols in a file:
# Get outline of main symbols (classes, functions, methods)
lsp outline main.py
# Include all symbols (variables, parameters, etc.)
lsp outline utils.py --all
Get Hover Information
Get documentation and type information for a symbol:
# Get hover info at a specific line
lsp hover main.py --scope 42
# Find symbol and get hover info
lsp hover models.py --find "process_data<HERE>"
Commands
| Command | Description | Alias |
|---|---|---|
definition |
Find symbol definition, declaration, or type definition | def |
hover |
Get hover information (type info, documentation) | - |
reference |
Find symbol references or implementations | ref |
outline |
Get a structured symbol outline for a file | - |
symbol |
Get detailed symbol information at a specific location | sym |
search |
Search for symbols across the entire workspace by name | - |
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.
Usage Tips
Locating Symbols
LSP CLI offers flexible ways to locate symbols in your code:
-
Line-based: Use
--scopewith a line number (1-based)lsp definition main.py --scope 42
-
Range-based: Specify a line range
lsp symbol utils.py --scope 10,20
-
Text-based: Use
--findto search for text with a markerlsp hover app.py --find "my_function<HERE>()" # The <HERE> marker indicates the cursor position
-
Symbol path: Navigate using symbol hierarchy
lsp definition models.py --scope "UserClass.get_name"
Markdown Output
For better readability or integration with documentation tools:
lsp hover main.py --scope 10 --markdown
Working with Results
Pagination for large result sets:
# Get first 50 results
lsp search "config" --max-items 50
# Get next page
lsp search "config" --max-items 50 --start-index 50
Debugging
Enable debug mode to see detailed logs:
lsp --debug definition main.py --scope 10
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).
Available Settings
Create a config.toml file at the location above with the following options:
# Enable debug mode (verbose logging)
debug = false
# Idle timeout for managed servers (in seconds)
idle_timeout = 600
# Log level: TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL
log_level = "INFO"
# Show ASCII art banner on startup
show_banner = true
# Default maximum items for paginated results (search, reference, etc.)
# Set to null for no limit, or a number like 20
default_max_items = 20
# Default number of context lines for reference results
default_context_lines = 2
# Paths to ignore in search results (e.g., virtual environments, build directories)
ignore_paths = [".git", "node_modules", "venv", ".venv", "__pycache__", "dist", "build"]
Environment Variables
All settings can be overridden via environment variables:
export LSP_DEBUG=true
export LSP_LOG_LEVEL=DEBUG
export LSP_DEFAULT_MAX_ITEMS=50
export LSP_SHOW_BANNER=false
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lsp_cli-0.0.1.tar.gz.
File metadata
- Download URL: lsp_cli-0.0.1.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30e99ef978ff8e69faae562ca599f697d3c5e18052e752f833134e5734d7a45c
|
|
| MD5 |
3604292c910cfe30b8619d4b2722a706
|
|
| BLAKE2b-256 |
6dad0535e418d9b1f3c62236cec1c6a28ffe06c320ece625503c3442f5566bfd
|
Provenance
The following attestation bundles were made for lsp_cli-0.0.1.tar.gz:
Publisher:
release.yml on lsp-client/lsp-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lsp_cli-0.0.1.tar.gz -
Subject digest:
30e99ef978ff8e69faae562ca599f697d3c5e18052e752f833134e5734d7a45c - Sigstore transparency entry: 796372832
- Sigstore integration time:
-
Permalink:
lsp-client/lsp-cli@33b736ab6e8e1709c1cf2c9f8e7871ac726e3b05 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/lsp-client
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@33b736ab6e8e1709c1cf2c9f8e7871ac726e3b05 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lsp_cli-0.0.1-py3-none-any.whl.
File metadata
- Download URL: lsp_cli-0.0.1-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7cb1849862811a74691c21bfc3a356e1deb21c8d3252638a6d781c7167f6762
|
|
| MD5 |
a7c0ea0a1b1ed0a6c845725c051c44eb
|
|
| BLAKE2b-256 |
7556ddb75ff3a19b54543d7b27e56f3fb1cca34e6b68782265d1c20cb6fda959
|
Provenance
The following attestation bundles were made for lsp_cli-0.0.1-py3-none-any.whl:
Publisher:
release.yml on lsp-client/lsp-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lsp_cli-0.0.1-py3-none-any.whl -
Subject digest:
b7cb1849862811a74691c21bfc3a356e1deb21c8d3252638a6d781c7167f6762 - Sigstore transparency entry: 796372841
- Sigstore integration time:
-
Permalink:
lsp-client/lsp-cli@33b736ab6e8e1709c1cf2c9f8e7871ac726e3b05 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/lsp-client
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@33b736ab6e8e1709c1cf2c9f8e7871ac726e3b05 -
Trigger Event:
push
-
Statement type: