Provides refactoring tools for JavaScript code through LSP integration, including symbol renaming, reference finding, function extraction, and code movement capabilities.
Provides refactoring tools for Python code through LSP integration, including symbol renaming, reference finding, function extraction, and code movement capabilities.
Provides refactoring tools for TypeScript code through LSP integration, including symbol renaming, reference finding, function extraction, and code movement capabilities.
LSP MCP Server
An LSP (Language Server Protocol) MCP (Model Context Protocol) server that provides refactoring tools through LSP integration. This server exposes refactoring capabilities as MCP tools that can be used by MCP clients like Claude Code.
Installation
From npm (when published)
Local Development Setup
Clone the repository:
git clone <repository-url> cd lsp-mcp-serverInstall dependencies:
pnpm installBuild the project:
pnpm run buildLink for global use:
npm linkAfter linking, you can use the
mcp-lsp
command globally.Alternative: Use without linking:
# Run directly pnpm start # Or build and run pnpm run dev
Prerequisites
The server requires these language servers to be installed for full functionality:
TypeScript/JavaScript
Python
Usage
With Claude Code
Quick Setup (Recommended)
If you have the server installed globally:
Using the Tools in Claude Code
Once connected, you can ask Claude Code to use the refactoring tools:
"Rename the
"Find all references to the
"Extract lines 20-35 from src/components/Header.tsx into a new function called
"Move the
"Rename the file src/old-name.ts to src/new-name.ts"
Claude Code will automatically use the appropriate LSP refactoring tools based on your requests.
Manual MCP Server Usage
The server can also be used directly by other MCP clients via stdio:
Available Tools
rename_file - Rename files/folders using LSP rename capabilities
move_function - Move functions between files using LSP refactoring
extract_function - Extract code selections into new functions
find_references - Find all references to symbols
rename_symbol - Rename symbols across all files
Example Tool Usage
Each tool accepts parameters specific to the refactoring operation:
rename_symbol: Requires
file
,line
,newName
, and optionallycharacter
andlanguage
find_references: Requires
file
,line
, and optionallycharacter
andlanguage
extract_function: Requires
file
,startLine
,endLine
,functionName
, and optionally character positions andlanguage
Supported Languages
TypeScript/JavaScript
Python
Development
Commands
pnpm install
- Install dependenciespnpm run build
- Compile TypeScript to dist/pnpm start
- Run the compiled serverpnpm run dev
- Build and run in one commandpnpm run type-check
- Check types without buildingpnpm run lint
- Check code with ESLintpnpm run lint:fix
- Auto-fix linting issuespnpm run format
- Format code with Prettierpnpm run clean
- Remove dist/ directory
Architecture
The server consists of:
LSPRefactorServer: Main server class implementing MCP interface
LSP Client Management: Manages connections to language servers
Tool Implementations: Each refactoring operation communicates with LSP servers
Protocol Communication
MCP Protocol: Server ↔ MCP clients via stdio
LSP Protocol: Server ↔ Language servers via JSON-RPC over stdio
local-only server
The server can only run on the client's local machine because it depends on local resources.
Provides code refactoring capabilities for TypeScript/JavaScript and Python through Language Server Protocol integration. Enables renaming symbols, extracting functions, finding references, and moving code between files via natural language commands.