lsp-mcp 0.1.0

MCP server providing unified access to Language Server Protocol features
Documentation

LSP MCP Server

An MCP (Model Context Protocol) server that provides unified access to Language Server Protocol features for multiple programming languages.

Features

  • Multi-language support: Rust, TypeScript/JavaScript, Python, Go, C/C++
  • Full IDE features exposed as MCP tools:
    • lsp_hover - Type info and documentation
    • lsp_goto_definition - Navigate to symbol definitions
    • lsp_find_references - Find all usages of a symbol
    • lsp_completion - Code completion suggestions
    • lsp_document_symbols - List symbols in a file
    • lsp_workspace_symbols - Search symbols across workspace
    • lsp_rename_symbol - Rename symbols across files
    • lsp_diagnostics - Get errors and warnings

Prerequisites

Language servers must be installed and available in PATH:

Language Server Install
Rust rust-analyzer rustup component add rust-analyzer
TypeScript/JS typescript-language-server npm i -g typescript-language-server typescript
Python pyright npm i -g pyright or pip install pyright
Go gopls go install golang.org/x/tools/gopls@latest
C/C++ clangd Install via system package manager

Installation

cargo install --path .

Usage

As MCP Server

Add to your MCP client configuration:

{
  "mcpServers": {
    "lsp": {
      "command": "lsp-mcp"
    }
  }
}

Tool Examples

1. Activate a workspace first:

{
  "tool": "lsp_activate_workspace",
  "arguments": {
    "workspace_path": "C:/path/to/project"
  }
}

2. Get hover info:

{
  "tool": "lsp_hover",
  "arguments": {
    "file_path": "C:/path/to/project/src/main.rs",
    "line": 10,
    "character": 5
  }
}

3. Find definition:

{
  "tool": "lsp_goto_definition",
  "arguments": {
    "file_path": "C:/path/to/project/src/main.rs",
    "line": 15,
    "character": 12
  }
}

4. Find references:

{
  "tool": "lsp_find_references",
  "arguments": {
    "file_path": "C:/path/to/project/src/main.rs",
    "line": 5,
    "character": 7,
    "include_declaration": true
  }
}

Development

# Build

cargo build


# Run in development

cargo run


# Run tests

cargo test


# Build release

cargo build --release

Architecture

lsp-mcp/
├── src/
│   ├── main.rs           # Entry point
│   ├── lib.rs            # Public API
│   ├── error.rs          # Error types
│   ├── server/           # MCP server
│   │   └── mcp_server.rs # Tool registration
│   ├── lsp/              # LSP client layer
│   │   ├── client.rs     # LSP client wrapper
│   │   ├── manager.rs    # Multi-server manager
│   │   ├── config.rs     # Server configurations
│   │   └── transport.rs  # Stdio transport
│   └── tools/            # MCP tools
│       ├── workspace.rs  # Workspace management
│       ├── hover.rs      # Hover info
│       ├── definition.rs # Go to definition
│       └── ...           # Other tools

License

MIT