[BUG] LSP tool: line and character parameters incorrectly converted to negative numbers
[BUG] LSP tool: line and character parameters incorrectly converted to negative numbers
Environment
- Claude Code Version: 2.1.77
- Platform: macOS (Darwin 25.3.0)
- Shell: zsh
Bug Description
When invoking the LSP tool with valid positive integers for line and character parameters, Claude Code incorrectly converts them to large negative numbers before sending to the LSP server, causing validation errors.
Expected Behavior
Calling LSP(operation: "hover", line: 3, character: 15) should send line=3, character=15 to the LSP server.
Actual Behavior
The parameters are converted to large negative numbers:
InputValidationError: [
{
"origin": "number",
"code": "too_small",
"minimum": 0,
"inclusive": false,
"path": ["line"],
"message": "Too small: expected number to be >0"
},
{
"origin": "number",
"code": "too_small",
"minimum": 0,
"inclusive": false,
"path": ["character"],
"message": "Too small: expected number to be >0"
}
]
Evidence
Error logs show the actual values being sent:
- Input:
line: 3, character: 15 - Output:
line: -1555781, character: -1555799(example values)
This suggests an integer overflow or incorrect type coercion in the parameter handling code.
Verification Steps
- LSP Server is running correctly:
``bash``
$ ps aux | grep typescript-language-server
node /path/to/typescript-language-server --stdio
- LSP Server responds correctly to direct JSON-RPC:
``javascript``
// Test with direct node.js spawn
const lsp = spawn('typescript-language-server', ['--stdio']);
// Send initialize request
// Returns correct capabilities
- mcp__ide__getDiagnostics works fine:
- Returns diagnostics for 69+ files correctly
- Confirms LSP infrastructure is functional
- LSP tool fails with parameter validation:
- Any operation (hover, documentSymbol, goToDefinition) fails
- Error shows negative line/character values
Reproduction
Minimal reproduction:
// Any TypeScript file in a project with tsconfig.json
LSP({
operation: "hover",
filePath: "/path/to/project/src/index.ts",
line: 3,
character: 15
})
Impact
- All LSP code intelligence features unusable via the
LSPtool - Workaround: Use
mcp__ide__getDiagnosticsfor basic diagnostics - No workaround for go-to-definition, hover, find-references, etc.
Related Issues
- #30948 - LSP workspaceSymbol missing query parameter
- #29858 - TypeScript LSP plugin race condition
Suggested Fix
Investigate parameter serialization in the LSP tool wrapper. The conversion from positive to negative integers suggests:
- Signed integer overflow
- Incorrect bit-width handling
- Type coercion from string to number with sign bit issues
---
Note: LSP servers (typescript-language-server, jdtls) are installed and running correctly. The issue is specifically in Claude Code's parameter handling before the request reaches the LSP server.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗