LSP Client for AI Validation
Atmos includes an LSP client that connects to external Language Server Protocol (LSP) servers for file validation. This enables Atmos AI to detect syntax errors, validate YAML structure, and check Terraform/HCL syntax with precise line numbers and warnings.
For IDE integration (validation, autocomplete, hover docs), see the LSP Server.
The LSP Client connects to external language servers (yaml-language-server, terraform-ls) to validate generic YAML/Terraform/HCL syntax. It is used internally by Atmos AI via the validate_file_lsp tool — you don't interact with it directly.
How the LSP Client Works
Atmos is an LSP client, not a server. It manages and communicates with external LSP servers (yaml-language-server, terraform-ls, etc.) to validate files when requested by Atmos AI.
Architecture:
┌─────────────────────┐
│ Atmos AI Chat │
│ (ai chat, mcp) │
└──────────┬──────────┘
│
│ validate_file_lsp tool
↓
┌─────────────────────┐
│ Atmos LSP Client │
│ (pkg/lsp/client) │
└──────────┬──────────┘
│
┌─────┴─────┬──────────┐
↓ ↓ ↓
┌─────────┐ ┌─────────┐ ┌──────────┐
│ YAML LS │ │ TF LS │ │ JSON LS │
│(external│ │(external│ │(external │
│ process)│ │ process)│ │ process) │
└─────────┘ └─────────┘ └──────────┘
Process Model:
- LSP servers run automatically in the background as child processes
- Servers start when Atmos needs to validate a file
- Servers shut down automatically when Atmos exits
- No manual server management required
Communication:
- Atmos communicates with LSP servers via stdin/stdout
- Each server runs as an independent subprocess
- All validation happens locally on your machine
Quick Start
Get started with LSP validation in 3 steps:
1. Install LSP Servers
Install the LSP servers you need:
These are standard LSP servers used by many editors. You may already have them installed if you use VS Code, Neovim, or other modern editors.
2. Enable LSP in atmos.yaml
Add LSP configuration to your atmos.yaml:
3. Use LSP Validation with Atmos AI
Once configured, Atmos AI can use LSP for file validation:
When you first enable LSP, Atmos will:
- Start LSP servers on-demand when AI requests validation (1-2 second startup)
- Cache validation results for fast subsequent checks
- Automatically clean up server processes on exit
The LSP client is used by Atmos AI via the validate_file_lsp tool.
Configuration Reference
lsp.enabled- Enable LSP integration globally (default:
false) lsp.servers.{name}.command- Command to start the LSP server (must be in PATH or absolute path)
lsp.servers.{name}.args- Arguments to pass to the LSP server command
lsp.servers.{name}.filetypes- List of file extensions this server handles (e.g.,
["yaml", "yml"]) lsp.servers.{name}.root_patterns- Files/directories that identify the project root (e.g.,
[".git", "atmos.yaml"]) lsp.servers.{name}.initialization_options- Server-specific initialization options (varies by LSP server)
Supported LSP Servers
- yaml-language-server — YAML, YML
- Install:
npm install -g yaml-language-server. YAML validation and schemas. - terraform-ls — TF, TFVARS, HCL
- Install:
brew install terraform-ls. Terraform/HCL validation. - vscode-json-languageserver — JSON
- Install:
npm install -g vscode-json-languageserver. JSON validation and schemas.
Optional: Using LSP in Your Editor
You can optionally configure your code editor to use the same external LSP servers (yaml-ls, terraform-ls) that Atmos uses. This provides real-time editing features like autocomplete, hover documentation, and inline error checking while you edit Atmos files.
These editor configurations are entirely optional and separate from the Atmos LSP client described above. The Atmos LSP client works independently for AI validation regardless of your editor setup.
See the LSP Server Editor Configuration for detailed setup instructions for VS Code, Neovim, Zed, Helix, Sublime Text, Emacs, IntelliJ, Vim, Kate, Lapce, and Nova.
AI Integration Configuration
The LSP client is automatically available to Atmos AI when enabled. AI can use it for file validation via the validate_file_lsp tool.
Complete Configuration Example
AI Validation Example
See AI Configuration for more details on AI integration.
Troubleshooting
LSP Server Not Found
Solution:
- Verify server is installed
- Ensure server command is in your PATH
- Use absolute path in configuration if needed:
command: "/usr/local/bin/yaml-language-server"
LSP Not Validating Files
Symptoms:
- No errors/warnings shown for invalid files
- LSP appears to not be running
Solutions:
- Verify
lsp.enabled: trueinatmos.yaml - Check server configuration matches your file types
- Ensure server command is correct and in PATH
- Check Atmos logs for LSP initialization errors:
ATMOS_LOGS_LEVEL=Debug atmos <command>
AI Not Using LSP
Symptoms:
- AI doesn't offer to validate files
validate_file_lsptool not available
Solutions:
- Enable AI tools:
ai.tools.enabled: true - Ensure
validate_file_lspis not inblocked_toolslist:
ai:
tools:
enabled: true
blocked_tools: [] # Don't block validate_file_lsp
LSP Server Crashes
Symptoms:
- Server stops responding
- Validation hangs or times out
Solutions:
- Check server logs for errors
- Verify
initialization_optionsare correct for your server version - Test server manually:
# YAML LS
yaml-language-server --stdio
# Type: {"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}
# Terraform LS
terraform-ls serve
- Try updating the LSP server to the latest version
File Type Not Detected
Symptoms:
- Validation doesn't run for certain files
- Wrong LSP server used for file
Solutions:
- Check
filetypesconfiguration matches file extension - Verify file extension is correct (e.g.,
.yamlnot.yml) - Add multiple extensions to
filetypes:
filetypes: ["yaml", "yml", "yaml.template"]
Performance Considerations
LSP servers run as background processes:
- Memory: Each server uses 50-200MB RAM
- Startup: Servers initialize on first file validation (~1-2 seconds)
- Caching: LSP servers cache parsed files for fast subsequent validations
Optimization Tips
- Only configure needed servers: Don't enable LSP servers for file types you don't use
- Automatic cleanup: LSP servers shut down automatically when Atmos exits
- Disable unused features: Use
initialization_optionsto disable unused features:
initialization_options:
yaml:
hover: false # Disable if only validating
completion: false # Disable if only validating
Multiple Servers
You can run multiple LSP servers simultaneously:
Each server handles its configured file types independently.
Security
External LSP servers run locally as subprocesses and communicate via stdio. They have read access to file contents sent for validation. Only use servers from trusted sources (yaml-language-server, terraform-ls).
Related Documentation
- LSP Server — IDE integration for Atmos-specific validation
- AI Configuration — Configure AI to use LSP
- AI Tools — Tool permissions and configuration
- Troubleshooting — Common LSP issues