LSP MCP Server
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.
README
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)
npm install -g lsp-mcp-server
Local Development Setup
-
Clone the repository:
git clone <repository-url> cd lsp-mcp-server -
Install dependencies:
pnpm install -
Build the project:
pnpm run build -
Link for global use:
npm linkAfter linking, you can use the
mcp-lspcommand 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
npm install -g typescript-language-server typescript
Python
# Default LSP server for type checking and refactoring
npm install -g pyright
# Optional: For linting (when using serverType: 'lint')
pip install ruff
Usage
With Claude Code
Quick Setup (Recommended)
If you have the server installed globally:
/mcp add lsp-mcp
Using the Tools in Claude Code
Once connected, you can ask Claude Code to use the refactoring tools:
- "Rename the
calculateTotalfunction tocomputeSumin src/utils.ts on line 45" - "Find all references to the
UserServiceclass in src/services/user.ts line 12" - "Extract lines 20-35 from src/components/Header.tsx into a new function called
renderNavigation" - "Move the
validateEmailfunction from src/utils/validation.ts line 8 to src/utils/email.ts" - "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:
mcp-lsp
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 optionallycharacterandlanguage - find_references: Requires
file,line, and optionallycharacterandlanguage - 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
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.