LSP MCP Server Bridge for Claude Code

1.1.15 · active · verified Tue Apr 21

The `lsp-mcp-server` package acts as a crucial intermediary, bridging the gap between AI models like Claude Code (using the Model Context Protocol, MCP) and existing Language Server Protocol (LSP) servers. This enables powerful semantic code intelligence features within AI-powered development environments, including go-to-definition, find references, code completion, diagnostics, and safe renames across 10 different programming languages such as TypeScript/JavaScript, Python, Rust, Go, and Java. It supports multi-root workspaces for monorepos, provides push-based diagnostics, and features automatic language server management. The current stable version is 1.1.15, indicating active development and maintenance. Its key differentiator is providing a robust, configurable, and secure integration layer for AI agents to leverage the rich capabilities of established LSP ecosystems without directly reimplementing language-specific intelligence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically import and conceptually interact with `lsp-mcp-server` functions, although its primary usage is as a CLI tool. It highlights the `startServer` function and explains that the server is typically launched as a separate process configured by an MCP client like Claude Code.

import { startServer } from 'lsp-mcp-server';

// A minimal example showing how to programmatically start the server.
// In a real scenario, this server would typically be launched via a CLI
// command or an external system like Claude Code as configured in ~/.mcp.json.

async function runLspMcpServer() {
  console.log('Starting lsp-mcp-server programmatically...');
  try {
    // In a production setup, command-line arguments would be parsed.
    // For this example, we'll simulate a minimal configuration.
    // The server listens on stdio by default when launched as a process.
    // Programmatic start might require more explicit config or a mock stdio stream.
    // The 'main' function typically handles argument parsing.
    // For simplicity, we'll just demonstrate importing a function.

    // To truly run it, you'd typically execute the built CLI:
    // `node dist/index.js --stdio` or `lsp-mcp-server --stdio`

    // Example of calling the main CLI entry point programmatically (if configured for direct call):
    // await main(); // This would block and expect stdio for LSP/MCP communication

    // For demonstration, let's just log and show a conceptual start.
    console.log('lsp-mcp-server is designed to be run as a background process, listening on stdio.');
    console.log('Refer to the README for installation and configuration with Claude Code.');
    console.log('Example command line invocation: lsp-mcp-server --stdio');
    
    // In a realistic scenario, you might do something like this for testing:
    // const serverInstance = new LspMcpServer(/* config */);
    // await serverInstance.start();

    // This quickstart focuses on showing the import, not a fully functional embedded server, 
    // as its primary use case is CLI-based.

  } catch (error) {
    console.error('Failed to start lsp-mcp-server:', error);
    process.exit(1);
  }
}

// To run this script, you would first need to install and build the package:
// npm install && npm run build
// then `node your-script.js`

runLspMcpServer();

view raw JSON →