LSP MCP Server
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.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LSP MCP Server rename the calculateTotal function to computeSum in src/utils.ts on line 45"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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-serverLocal 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-lspcommand globally.Alternative: Use without linking:
# Run directly pnpm start # Or build and run pnpm run dev
Related MCP server: ts-mcp
Prerequisites
The server requires these language servers to be installed for full functionality:
TypeScript/JavaScript
npm install -g typescript-language-server typescriptPython
# Default LSP server for type checking and refactoring
npm install -g pyright
# Optional: For linting (when using serverType: 'lint')
pip install ruffUsage
With Claude Code
Quick Setup (Recommended)
If you have the server installed globally:
/mcp add lsp-mcpUsing 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-lspAvailable 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 optionallycharacterandlanguagefind_references: Requires
file,line, and optionallycharacterandlanguageextract_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
Available Tools
5 toolsextract_functionC
Extract selected code into a new function
Inputs: file (required), startLine (required), endLine (required), functionName (required), +3 more.
find_referencesC
Find all references to a symbol using LSP
Inputs: file (required), line (required), character, language.
move_functionB
Move a function to a different file using LSP refactoring
Inputs: sourceFile (required), targetFile (required), functionName (required), line (required), +2 more.
rename_fileC
Rename a file or folder using LSP rename capabilities
Inputs: oldPath (required), newPath (required), language.
rename_symbolB
Rename a symbol (variable, function, class, etc.) across all files
Inputs: file (required), line (required), newName (required), character, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct purpose with no overlap: extract_function creates new functions, find_references locates symbol usage, move_function relocates functions between files, rename_file handles file/folder renaming, and rename_symbol renames symbols across files. The descriptions make it impossible to confuse one tool for another.
All tool names follow a consistent verb_noun pattern (e.g., extract_function, find_references, move_function, rename_file, rename_symbol). The naming is perfectly uniform with no deviations in style or convention.
With 5 tools, this server is well-scoped for LSP-based code refactoring and navigation. Each tool earns its place by covering distinct refactoring operations without being too sparse or bloated.
The toolset covers key LSP refactoring operations (extract, move, rename) and symbol navigation (find references), but lacks tools for other common LSP features like code completion, diagnostics, or formatting. However, the provided tools form a coherent subset for core refactoring tasks.
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Coding agents in multi-service codebases routinely rebuild existing helpers, trust stale type definitions, and modify API contracts without knowing who consumes them. Carrick solves this by indexing your entire TypeScript ecosystem across service and repository boundaries. By integrating deeply with the TypeScript compiler, Carrick traces every route, type, and cross-service call while recording function behaviour so agents search by intent rather than name. Delivered via MCP for AI agents and LSP for IDEs, Carrick ensures models see existing endpoints and utilities before generating new code. The scanner is source-available and runs from your CLI or CI pipeline.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Ask a codebase what calls what: search, blast radius, paths between symbols, and diffs.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables coding agents to perform safe, project-wide Python refactoring (rename, move, extract, inline, change signature, organize imports, etc.) with a dry-run safety contract and LSP-coordinate addressing.15MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to navigate and edit TypeScript/JavaScript source by named declarations, reading symbols, imports, diagnostics, and replacing code via the TypeScript AST.-
- AlicenseNot gradedqualityBmaintenanceEnables AI coding agents to perform structural code operations on TypeScript/TSX projects—finding symbols and references and renaming them semantically while preserving source.27 npmMIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to navigate and refactor a codebase through an AST index, offering project overviews, symbol and usage search, module dependency exploration, and LSP-backed operations such as rename, go-to-definition, diagnostics, and extract-method. Supports TypeScript/JavaScript and C# with automatic reindexing and watch mode.MIT