So by chance had the OUTPUT tab open instead of the TERMINAL tab in VS Code so decided to read the messages while Claude was working. Spotted LSP in the stream right after an SWI-Prolog *.pl file was listed.
Asked Claude to create the following markdown document (which has not been verified). This sheds more light with details on my earlier reply.
Claude Code LSP Integration Guide
Claude Code LSP Integration Guide
Last Updated: 2025-12-12
Audience: Beginners to Prolog, LSP, and Claude Code
Purpose: Understanding if and how Claude Code can integrate with Language Server Protocol (LSP) for SWI-Prolog development
Table of Contents
- What is LSP?
- What is Claude Code?
- Understanding the Log Messages
- Can Claude Code Integrate with LSP?
- SWI-Prolog LSP Implementations
- MCP Server Options for Enhanced Integration
- Comparison of LSP Integration Approaches
- Claude Code for VS Code: Known Issues
- Troubleshooting
- Resources
What is LSP?
Language Server Protocol (LSP) is a standardized protocol that allows code editors (like VS Code) to communicate with language-specific tools that provide:
- Error checking (syntax errors, type errors)
- Autocomplete (intelligent code suggestions)
- Go to definition (jump to where functions/predicates are defined)
- Find references (see where code is used)
- Hover information (documentation popups)
- Linting warnings (code quality suggestions)
Why LSP Matters
Before LSP, every editor needed custom support for each programming language. LSP standardizes this:
Editor (VS Code) <--> LSP Protocol <--> Language Server (Prolog LSP)
This means one Prolog language server can work with any LSP-compatible editor.
LSP Diagnostics
Diagnostics are error messages, warnings, and hints about your code that the language server sends to your editor. When you see red squiggles under code with error messages, that’s LSP diagnostics in action.
What is Claude Code?
Claude Code is an AI-powered coding assistant that can:
- Read and analyze your codebase
- Write and edit code
- Debug problems
- Answer questions about your code
- Run tests and build commands
Claude Code Variants
- CLI Tool - Command-line interface for terminal use
- VS Code Extension - Integrated into Visual Studio Code
- JetBrains Plugin - For IntelliJ, PyCharm, etc.
How Claude Code Uses LSP
Claude Code can integrate with LSP diagnostics to:
- See errors and warnings in your code automatically
- Understand what’s broken before you explain it
- Provide more accurate fixes
- Include diagnostic context in AI conversations
Understanding the Log Messages
When using Claude Code for VS Code, you may see messages like this in the OUTPUT tab:
2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.634Z [DEBUG] Hooks: Found 0 total hooks in registry
2025-12-11 15:26:17.497 [info] From claude: 2025-12-11T21:26:17.498Z [DEBUG] Total LSP servers loaded: 0
Message Breakdown
Message Structure
2025-12-11 20:11:46.635 [info] From claude: 2025-12-12T02:11:46.633Z [DEBUG] LSP Diagnostics: getLSPDiagnosticAttachments called
│ │ │ │ │ │
│ │ │ │ │ └─ Debug message
│ │ │ │ └─ Claude Code's internal log level
│ │ │ └─ Claude Code's timestamp (UTC)
│ │ └─ Message source identifier
│ └─ VS Code's log level
└─ VS Code's timestamp (local time)
Key Components
| Component |
Meaning |
[info] From claude: |
Message originated from Claude Code extension |
[DEBUG] |
Internal debug-level logging from Claude Code |
getLSPDiagnosticAttachments called |
Claude Code is checking for LSP diagnostics to include in AI context |
Checking registry - 0 pending |
No diagnostics found in the internal registry |
Total LSP servers loaded: 0 |
No LSP servers are currently connected to Claude Code |
What Does “getLSPDiagnosticAttachments” Mean?
This is an internal function that:
- Runs when: Claude Code prepares to send a message to the AI
- Purpose: Gather any LSP diagnostics (errors/warnings) from your code
- Action: Packages diagnostics as “attachments” to include in the conversation
- Result: Returns empty if no diagnostics found
Flow:
User sends message to Claude
↓
Claude Code prepares AI request
↓
getLSPDiagnosticAttachments() called
↓
Checks LSP diagnostic registry
↓
Finds: "0 pending" (no errors/warnings)
↓
Message sent to AI without diagnostic context
Why “0 LSP servers loaded”?
This message indicates no LSP servers are connected to Claude Code. This means:
Claude Code’s LSP integration system is running
No language servers are connected to it
Claude Code cannot see LSP diagnostics from your editor
This is a configuration gap, not a fundamental limitation.
Can Claude Code Integrate with LSP?
Short Answer
Yes, but with limitations and workarounds needed.
Detailed Answer
Built-in Support
Claude Code version 2.0.30+ (October 31, 2024) includes:
Basic LSP support system
Automatic diagnostic sharing in VS Code extension
$ENABLE_LSP_TOOL=1 environment variable to enable LSP tool
Still early/raw - bugs exist, limited documentation
Current Limitations (as of 2025-12-12)
-
VS Code Extension Paradox
- CLI version has better IDE integration than the native VS Code extension
- VS Code extension missing the
mcp__ide__getDiagnostics MCP tool
- Source: Issue #8635
-
No UI Indication
- No visual feedback when LSP servers start/stop
- No indication of errors in LSP server connections
- Debug logs are the only way to see status
-
Limited Documentation
- Official docs don’t detail LSP setup
- Community-driven workarounds needed
Two Integration Levels
Level 1: VS Code Native LSP (Working)
Your Code <--> Prolog LSP Server <--> VS Code
│
└─> Shows errors in Problems panel
VS Code itself can use Prolog LSP servers to show you errors, regardless of Claude Code.
Level 2: Claude Code Access to LSP (Needs Configuration)
Your Code <--> Prolog LSP Server <--> VS Code <--> Claude Code Extension
│
└─> Claude sees diagnostics
This requires additional setup using MCP servers or waiting for improved built-in support.
SWI-Prolog LSP Implementations
Overview
There are two main LSP server implementations for SWI-Prolog:
| Implementation |
Maturity |
Recommended |
Platform Support |
| lsp_server by jamesnvc |
Mature |
Yes |
Linux, macOS, Windows (with caveats) |
| prolog_lsp by hargettp |
Experimental |
No |
All platforms (but immature) |
Option 1: lsp_server (Recommended)
Repository: GitHub - jamesnvc/lsp_server: Language Server Protocol server for SWI-Prolog
SWI-Prolog Pack: "lsp_server" pack for SWI-Prolog
Maturity: Production-ready
Features
Find definitions
Find references
Hover documentation
Code completion
Diagnostics (errors/warnings)
Signature help
Installation
Method 1: Using pack_install
?- pack_install(lsp_server).
Method 2: Using swipl command
swipl pack install lsp_server
Requirements
- SWI-Prolog 8.1.5 or newer (for best results with “find references”)
- Requires
xref_called/5 predicate (available in 8.1.5+)
Windows-Specific Configuration
IMPORTANT: On Windows (not WSL), running the server via stdio will NOT work.
Solution: Run the server over a socket instead:
# Start lsp_server on a specific port
swipl -g "lsp_server:main([port, 5007])" -t halt
As of version 2.5.0, socket mode is supported via command-line arguments:
port <port_number>
instead of stdio.
VS Code Extension: swi-lsp
Marketplace: swi-lsp - Visual Studio Marketplace
This extension provides VS Code integration for lsp_server.
Installation:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X)
- Search for “swi-lsp”
- Click Install
Configuration: See the extension’s README for connecting to the LSP server.
Option 2: prolog_lsp (Experimental)
Repository: GitHub - hargettp/prolog_lsp: Language Server for Prolog
SWI-Prolog Pack: "prolog_lsp" pack for SWI-Prolog
Maturity:
Experimental (not recommended for production)
Status
From the author:
“This project is very immature and not at all recommended for daily production use.”
When to Consider
- You want to contribute to LSP development
- You’re experimenting with alternative implementations
- You need features not yet in lsp_server
MCP Server Options for Enhanced Integration
Model Context Protocol (MCP) servers can bridge the gap between Claude Code and LSP diagnostics.
What is MCP?
MCP is a protocol that allows AI assistants like Claude to access external tools and data sources. MCP servers act as middleware that:
- Connect Claude Code to LSP servers
- Expose LSP features as tools Claude can use
- Work around limitations in Claude Code’s built-in LSP support
Available MCP Servers for LSP Integration
1. cclsp (Claude Code LSP)
Repository: GitHub - ktnyt/cclsp: Claude Code LSP: enhance your Claude Code experience with non-IDE dependent LSP integration.
MCP Market: https://mcpmarket.com/server/cclsp
Features
Pull current diagnostics using textDocument/diagnostic
Find definitions, references, rename symbols
Server restart capabilities
Intelligent position handling (tries multiple combinations)
Robust symbol resolution
Why It Helps
Solves the common problem where AI agents struggle with accurate line/column numbers when communicating with LSP servers.
Use Case
You want Claude Code to have direct access to LSP features regardless of IDE limitations.
2. tritlo/lsp-mcp
Playbooks: LSP MCP server for AI agents
Features
Hover information
Code completions
Diagnostics
Generic LSP feature access for LLMs
Why It Helps
Provides a clean interface for AI agents to query LSP servers for any language.
Use Case
You want a language-agnostic MCP server that works with multiple LSP servers.
3. @juanpprieto/claude-lsp
NPM Package: https://www.npmjs.com/package/@juanpprieto/claude-lsp
Features
Hook-based diagnostic injection
Real-time code analysis
TypeScript LSP integration
ESLint checking
Prettier formatting
GraphQL checks
Why It Helps
Automatically injects diagnostics into Claude’s context using hooks, so Claude sees:
- Type errors
- Lint warnings
- Formatting issues
Use Case
You want automatic, real-time diagnostic sharing without manual intervention.
Comparison of MCP Servers
| Feature |
cclsp |
tritlo/lsp-mcp |
@juanpprieto/claude-lsp |
| Diagnostics |
 |
 |
 |
| Definitions |
 |
 |
 |
| References |
 |
 |
 |
| Hover Info |
 |
 |
 |
| Completions |
 |
 |
 |
| Auto-injection |
 |
 |
(via hooks) |
| Multi-language |
 |
 |
(JS/TS focused) |
| Position handling |
(robust) |
 |
 |
| Server restart |
 |
 |
 |
| Prolog support |
(any LSP) |
(any LSP) |
(JS/TS focused) |
Legend:
= Supported
= Not supported
= Unknown/unclear
= Partial support
Comparison of LSP Integration Approaches
Overview Table
| Approach |
Setup Complexity |
Claude Access |
Cost |
Maturity |
Platform Support |
| VS Code Native Only |
Low |
None |
Free |
Mature |
All |
| Built-in Claude Code LSP |
Low-Medium |
Limited |
Free |
Early/Raw |
All |
| MCP Server (cclsp) |
Medium |
Full |
Free |
Moderate |
All |
| MCP Server (tritlo) |
Medium |
Full |
Free |
Moderate |
All |
| MCP Server (@juanpprieto) |
Medium-High |
Auto |
Free |
Moderate |
All |
Detailed Comparison
1. VS Code Native LSP Only
Setup:
Install Prolog LSP extension (swi-lsp) → Configure → Done
Pros:
Simple setup
Works independently of Claude Code
Well-documented
Stable
Cons:
Claude Code cannot see diagnostics
No AI-assisted error fixing
Manual error explanation needed
Best For: Users who want VS Code LSP features but don’t need Claude to access diagnostics.
2. Built-in Claude Code LSP Support
Setup:
export ENABLE_LSP_TOOL=1
# Or set in VS Code settings
Pros:
No additional software needed
Official support from Anthropic
Automatic diagnostic sharing (in theory)
Cons:
Early/raw implementation (as of 2025-12)
Bugs in different LSP operations
No documentation
No UI indication of status
VS Code extension missing MCP tool
Best For: Early adopters willing to work through limitations while the feature matures.
3. MCP Server Integration (cclsp)
Setup:
# Install cclsp MCP server
npm install -g cclsp
# Configure in Claude Code settings
# Point to your Prolog LSP server
Pros:
Full LSP feature access
Robust position handling
Works around IDE limitations
Server restart capabilities
Language-agnostic
Cons:
Additional software to install
More complex configuration
Requires understanding of MCP
Best For: Power users who want complete LSP integration and are comfortable with configuration.
4. MCP Server Integration (tritlo/lsp-mcp)
Setup:
# Install and configure tritlo/lsp-mcp
# Connect to Prolog LSP server
Pros:
Generic LSP interface
Multi-language support
Hover, completions, diagnostics
Cons:
Additional software to install
Configuration complexity
Less documentation than cclsp
Best For: Users working with multiple languages who want one MCP server for all LSP interactions.
5. Hook-based Auto-injection (@juanpprieto/claude-lsp)
Setup:
npm install @juanpprieto/claude-lsp
# Configure hooks in Claude Code
# Set up automatic injection
Pros:
Automatic diagnostic injection
Real-time analysis
No manual triggering needed
Hook-based workflow integration
Cons:
Most complex setup
Primarily JS/TS focused (Prolog support unclear)
Requires hook configuration knowledge
Best For: TypeScript/JavaScript developers who want fully automatic diagnostic sharing; Prolog support uncertain.
Decision Matrix
Choose VS Code Native Only if:
- You only need LSP features in your editor
- You don’t need Claude to see diagnostics
- You want the simplest setup
Choose Built-in Claude Code LSP if:
- You’re okay with early-stage software
- You want official support
- You can wait for maturity improvements
Choose cclsp MCP Server if:
- You need full LSP feature access in Claude
- You want robust, reliable integration
- You’re comfortable with configuration
Choose tritlo/lsp-mcp if:
- You work with multiple languages
- You want a generic LSP solution
- You prefer flexibility over specialization
Choose @juanpprieto/claude-lsp if:
- You primarily work with TypeScript/JavaScript
- You want automatic diagnostic injection
- You’re willing to invest in complex setup
Claude Code for VS Code: Known Issues
This section documents specific issues when using Claude Code through the VS Code chat interface.
Issue 1: Missing MCP IDE Diagnostics Tool
Reference: Issue #8635
Problem:
- CLI version of Claude Code has
mcp__ide__getDiagnostics tool
- VS Code extension is missing this tool
- Paradox: External CLI has better IDE access than native extension
Impact:
- VS Code extension cannot retrieve Pylance/LSP diagnostics via MCP
- Reduces effectiveness compared to CLI version
- “Fix with Claude Code” feature may not work properly
Status: Open issue (as of 2025-12-12)
Workaround:
- Use CLI version with
--ide flag to connect to VS Code
- Use MCP servers (cclsp, tritlo/lsp-mcp) to bridge the gap
- Wait for official fix
Issue 2: LSP Integration Worse Than CLI
Reference: Issue #8635 (same issue)
Problem:
“The CLI version of Claude Code can connect to IDEs and access diagnostics. But the VSCode Extension (which runs inside the IDE) has worse IDE integration.”
Expected Behavior:
- VS Code extension should have better LSP access
- Should see all diagnostics automatically
- Should integrate seamlessly with native LSP features
Actual Behavior:
- Extension shows “Total LSP servers loaded: 0”
- Cannot access diagnostics that VS Code itself can see
- Requires workarounds to access native IDE features
Issue 3: “Fix with Claude Code” Action Broken
Reference: Issue #2269
Problem:
- “Fix with Claude Code” action in VS Code doesn’t work properly
- Diagnostic information not passed correctly to Claude
- May fail silently or provide incomplete context
Impact:
- Quick-fix workflow broken
- Must manually describe errors to Claude
- Reduces productivity
Workaround:
- Manually copy error messages to Claude chat
- Use terminal/CLI commands to run diagnostics
- Wait for official fix
Issue 4: No UI Indication of LSP Server Status
Problem:
- No visual feedback in VS Code about LSP server connections
- No way to know if LSP integration is working
- Must check OUTPUT tab logs to debug
Impact:
- Users unaware of connection issues
- Difficult to troubleshoot
- “0 LSP servers loaded” discovered only through logs
Workaround:
- Regularly check OUTPUT tab → Select “Claude Code” source
- Look for debug messages about LSP servers
- Monitor for “Total LSP servers loaded: X” messages
Issue 5: Early/Raw LSP Support
Reference: Issue #5495 discussion
Problem:
- LSP support added in v2.0.30 but still immature
- Bugs in different LSP operations
- Missing documentation
- No standardized configuration
Known Bugs:
- Socket vs stdio connection issues
- Server initialization failures
- Position/offset calculation errors
- Timeout issues (especially in JetBrains IDEs)
Workaround:
- Use
$ENABLE_LSP_TOOL=1 environment variable
- Report bugs to GitHub issues
- Use MCP servers for more stable integration
- Contribute to community testing
Issue 6: Windows-Specific Problems
Problem:
- Prolog LSP server (
lsp_server) doesn’t support stdio on Windows
- Must use socket mode instead
- Configuration more complex than Linux/macOS
Impact:
- Windows users need extra configuration steps
- May encounter connection errors with default settings
Solution:
Known Workarounds Summary
| Issue |
Workaround |
Effort |
Effectiveness |
| Missing MCP tool |
Use CLI with --ide flag |
Medium |
Good |
| Missing MCP tool |
Use cclsp/tritlo MCP server |
Medium-High |
Excellent |
| Poor LSP integration |
Use MCP servers |
Medium-High |
Excellent |
| “Fix with Claude” broken |
Manual error copying |
Low |
Partial |
| No UI indication |
Monitor OUTPUT logs |
Low |
Diagnostic only |
| Windows stdio issues |
Use socket mode |
Medium |
Good |
Troubleshooting
Problem: “Total LSP servers loaded: 0”
Symptoms:
[DEBUG] Total LSP servers loaded: 0
[DEBUG] LSP Diagnostics: Checking registry - 0 pending
Causes:
- No Prolog LSP server installed in VS Code
- LSP server installed but not connected to Claude Code
- Claude Code’s LSP integration not enabled
Solutions:
Step 1: Install Prolog LSP Server
# Install lsp_server pack
swipl -g "pack_install(lsp_server)" -t halt
# Or install VS Code extension
# Search "swi-lsp" in VS Code Extensions marketplace
Step 2: Enable Claude Code LSP Support
# Set environment variable
export ENABLE_LSP_TOOL=1
# Or in VS Code settings.json
{
"claude-code.enableLSP": true
}
Step 3: Verify LSP Server Running
- Open a Prolog file in VS Code
- Check Problems panel (Ctrl+Shift+M) for diagnostics
- If VS Code shows diagnostics, LSP server is working
Step 4: Install MCP Server (Alternative)
# Install cclsp
npm install -g cclsp
# Configure in Claude Code MCP settings
Problem: No Diagnostics Showing in VS Code
Symptoms:
- No errors/warnings in Problems panel
- Red squiggles not appearing under code
- LSP server seems not to work
Solutions:
Check 1: Is the LSP Extension Installed?
- Go to Extensions (Ctrl+Shift+X)
- Search “swi-lsp” or “prolog”
- Install if missing
Check 2: Is the LSP Server Running?
On Linux/macOS:
ps aux | grep lsp_server
On Windows:
Get-Process | Select-String "swipl"
Check 3: VS Code Output Logs
- Open OUTPUT tab (Ctrl+Shift+U)
- Select “SWI-Prolog Language Server” from dropdown
- Look for error messages
Check 4: Restart LSP Server
- Open VS Code Command Palette (Ctrl+Shift+P)
- Type “Reload Window”
- Or restart VS Code entirely
Problem: Windows Socket Connection Errors
Symptoms:
- LSP server fails to start
- “Connection refused” errors
- stdio-related errors
Solution:
Must use socket mode on Windows:
# Start LSP server on specific port
swipl -g "lsp_server:main([port, 5007])" -t halt
Configure VS Code extension (settings.json):
{
"swi-lsp.server.host": "localhost",
"swi-lsp.server.port": 5007
}
Problem: Claude Code Can’t See Diagnostics VS Code Shows
Symptoms:
- VS Code Problems panel shows errors
- Claude Code shows “0 pending” diagnostics
- LSP server working but Claude can’t access it
Root Cause:
- VS Code extension missing
mcp__ide__getDiagnostics tool
- Claude Code’s LSP integration not connected to VS Code’s LSP
Solutions:
Option 1: Use MCP Server
npm install -g cclsp
# Configure to connect to your Prolog LSP server
Option 2: Use CLI with IDE Connection
claude --ide vscode
Option 3: Wait for Official Fix
- Track Issue #8635
- Update to latest Claude Code version when fixed
Problem: “Fix with Claude Code” Does Nothing
Symptoms:
- Right-click on error → “Fix with Claude Code”
- Nothing happens or error appears
- Diagnostic not passed to Claude
Solution:
Manual Workaround:
- Copy the error message from Problems panel
- Open Claude Code chat
- Paste error and ask for fix
- Apply fix manually
Permanent Solution:
- Wait for Issue #2269 fix
- Use MCP server integration instead
Resources
Official Documentation
SWI-Prolog LSP Implementations
VS Code Extensions
MCP Servers
GitHub Issues
LSP Protocol Documentation
Community Resources
Appendix: Example VS Code Configuration
settings.json for SWI-Prolog LSP
{
// SWI-Prolog LSP Server Configuration
"swi-lsp.server.enabled": true,
"swi-lsp.server.host": "localhost",
"swi-lsp.server.port": 5007,
// Claude Code Configuration
"claude-code.enableLSP": true,
"claude-code.debug": true,
// Prolog File Associations
"files.associations": {
"*.pl": "prolog",
"*.pro": "prolog"
}
}
Environment Variables
# Enable Claude Code LSP tool
export ENABLE_LSP_TOOL=1
# Enable debug logging
export CLAUDE_CODE_DEBUG=1
Appendix: Starting LSP Server Manually
Linux/macOS
#!/bin/bash
# start-prolog-lsp.sh
# Start lsp_server in stdio mode
swipl -g "lsp_server:main([stdio])" -t halt
Windows (Socket Mode Required)
# start-prolog-lsp.ps1
# Start lsp_server in socket mode
& "C:\Program Files\swipl\bin\swipl.exe" -g "lsp_server:main([port, 5007])" -t halt
Summary
Key Takeaways
-
LSP is a protocol that connects editors to language-specific tools for error checking, autocomplete, and more.
-
Claude Code can integrate with LSP, but support is early/raw as of 2025-12-12.
-
“Total LSP servers loaded: 0” means no LSP servers are connected to Claude Code - this is a configuration issue, not a limitation.
-
For SWI-Prolog, use lsp_server by jamesnvc (mature) or the swi-lsp VS Code extension.
-
Windows users must use socket mode - stdio doesn’t work for lsp_server on Windows.
-
VS Code extension has limitations - missing MCP tool, worse than CLI version.
-
MCP servers (cclsp, tritlo/lsp-mcp) provide workarounds for Claude Code’s LSP integration gaps.
-
Multiple integration approaches exist - choose based on complexity tolerance and feature needs.
Quick Start Checklist
- Install SWI-Prolog (if not already installed)
- Install
lsp_server pack: ?- pack_install(lsp_server).
- Install
swi-lsp VS Code extension
- Configure socket mode (Windows) or stdio mode (Linux/macOS)
- Verify LSP works in VS Code (check Problems panel)
- Choose Claude Code integration approach:
- Built-in (simple, limited)
- MCP server (complex, full-featured)
- Enable
ENABLE_LSP_TOOL=1 if using built-in
- Test: Open Prolog file with errors, check if Claude sees them