Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>VSCode LSP MCP ServerNew to Visual Studio Code? Get it now.
VSCode LSP MCP Server

VSCode LSP MCP Server

trademe

| (0) | Free
Exposes VSCode Language Server Protocol functions as an MCP server for Claude Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VSCode LSP MCP Server

A VSCode extension that exposes Language Server Protocol (LSP) functions as an MCP (Model Context Protocol) server for Claude Code.

How It Works

This extension runs an HTTP server (using StreamableHTTP transport) inside VSCode that exposes LSP capabilities to Claude Code. When VSCode starts, the extension automatically launches the MCP server on port 37140 by default (or the next available port if it's in use). Claude Code connects to this server via HTTP to access VSCode's language intelligence features.

Features

This extension provides the following LSP capabilities to Claude Code through MCP tools:

  • workspace_symbols: Search for symbols across the entire workspace
  • document_symbols: Get all symbols in a specific document
  • find_references: Find all references/usages of a symbol
  • rename_symbol: Rename a symbol across the workspace
  • go_to_definition: Find the definition of a symbol
  • go_to_type_definition: Find the type definition of a symbol
  • go_to_implementation: Find the implementation of a symbol

Installation

1. Build the Extension

# Install dependencies
npm install

# Compile TypeScript
npm run compile

2. Install the Extension in VSCode

You have two options:

Option A: Install from VSIX (Recommended)

# Package the extension
npx vsce package

# Install the generated .vsix file in VSCode
code --install-extension vscode-lsp-mcp-0.1.0.vsix

Option B: Run in Development Mode

  1. Open this project in VSCode
  2. Press F5 to launch a new VSCode window with the extension loaded

3. Configure Claude Code

The extension runs an HTTP server (using StreamableHTTP transport) that starts automatically when VSCode launches. By default, it runs on port 37140 (configurable in VSCode settings).

Edit your Claude Code MCP configuration file:

  • macOS/Linux: ~/.config/claude-code/mcp_settings.json
  • Windows: %APPDATA%\claude-code\mcp_settings.json

Add the following configuration:

{
  "mcpServers": {
    "vscode-lsp": {
      "url": "http://localhost:37140"
    }
  }
}

Note: After installing the extension in VSCode, you'll see a notification showing which port the server started on. Update the port number in your Claude Code configuration to match.

4. Reload VSCode and Restart Claude Code

  1. Reload VSCode to activate the extension
  2. Restart Claude Code to connect to the MCP server

Configuration

Changing the Server Port

You can configure the port the MCP server listens on through VSCode settings:

  1. Open VSCode Settings (Cmd/Ctrl + ,)
  2. Search for "LSP MCP"
  3. Set "Server Port" to your desired port number (default: 37140)
  4. Reload VSCode for the change to take effect

Alternatively, add this to your VSCode settings.json:

{
  "vscode-lsp-mcp.serverPort": 37140
}

If the configured port is already in use, the extension will automatically try the next available port and notify you.

Autostart Configuration

By default, the MCP server does not start automatically when you open a workspace. You can enable autostart per workspace using one of these methods:

Using VSCode Commands

  1. Open the Command Palette (Cmd/Ctrl + Shift + P)
  2. Run LSP MCP: Enable Autostart for This Workspace to enable
  3. Or run LSP MCP: Disable Autostart for This Workspace to disable

Using VSCode Settings

Add this to your workspace .vscode/settings.json:

{
  "vscode-lsp-mcp.autostart": true
}

CLI Control via URL Scheme

You can control the MCP server from the command line using VSCode's custom URL scheme:

Start the Server

# macOS/Linux
open "vscode://trademe.vscode-lsp-mcp/start"

# Windows
start "vscode://trademe.vscode-lsp-mcp/start"

Stop the Server

# macOS/Linux
open "vscode://trademe.vscode-lsp-mcp/stop"

# Windows
start "vscode://trademe.vscode-lsp-mcp/stop"

Enable Autostart for Current Workspace

# macOS/Linux
open "vscode://trademe.vscode-lsp-mcp/enableAutostart"

# Windows
start "vscode://trademe.vscode-lsp-mcp/enableAutostart"

Disable Autostart for Current Workspace

# macOS/Linux
open "vscode://trademe.vscode-lsp-mcp/disableAutostart"

# Windows
start "vscode://trademe.vscode-lsp-mcp/disableAutostart"

Note: VSCode must be running and the extension must be installed for these commands to work.

Usage

Once configured, Claude Code will have access to the LSP tools. Here are some examples:

Search for Symbols

Find all functions named "handleRequest" in the workspace

Find References

Find all usages of the function at src/server.ts line 42, character 10

Rename Symbol

Rename the variable at src/utils.ts line 15, character 8 to "newVariableName"

Go to Definition

Show me the definition of the function at src/main.ts line 20, character 5

Tools Reference

workspace_symbols

Search for symbols across the entire workspace.

Parameters:

  • query (string): Search query for symbols (can be empty to list all symbols)

Example:

{
  "query": "handleRequest"
}

document_symbols

Get all symbols in a specific document.

Parameters:

  • uri (string): File path of the document

Example:

{
  "uri": "/path/to/src/server.ts"
}

find_references

Find all references/usages of a symbol.

Parameters:

  • uri (string): File path of the document
  • line (number): Line number (0-based)
  • character (number): Character position (0-based)
  • includeDeclaration (boolean, optional): Whether to include the declaration (default: true)

Example:

{
  "uri": "/path/to/src/server.ts",
  "line": 42,
  "character": 10
}

rename_symbol

Rename a symbol across the workspace.

Parameters:

  • uri (string): File path of the document
  • line (number): Line number (0-based)
  • character (number): Character position (0-based)
  • newName (string): New name for the symbol

Example:

{
  "uri": "/path/to/src/utils.ts",
  "line": 15,
  "character": 8,
  "newName": "newVariableName"
}

go_to_definition

Find the definition of a symbol.

Parameters:

  • uri (string): File path of the document
  • line (number): Line number (0-based)
  • character (number): Character position (0-based)

Example:

{
  "uri": "/path/to/src/main.ts",
  "line": 20,
  "character": 5
}

go_to_type_definition

Find the type definition of a symbol.

Parameters:

  • uri (string): File path of the document
  • line (number): Line number (0-based)
  • character (number): Character position (0-based)

go_to_implementation

Find the implementation of a symbol.

Parameters:

  • uri (string): File path of the document
  • line (number): Line number (0-based)
  • character (number): Character position (0-based)

Development

Project Structure

vscode-utils/
├── src/
│   ├── extension.ts              # VSCode extension entry point
│   ├── mcpServer.ts              # MCP server implementation
│   └── tools/                    # LSP tool handlers
│       ├── workspaceSymbols.ts
│       ├── documentSymbols.ts
│       ├── findReferences.ts
│       ├── renameSymbol.ts
│       ├── goToDefinition.ts
│       ├── goToTypeDefinition.ts
│       └── goToImplementation.ts
├── package.json
├── tsconfig.json
└── README.md

Available Scripts

  • npm run compile: Compile TypeScript to JavaScript
  • npm run watch: Watch for changes and recompile
  • npm run test: Run integration tests (downloads VSCode if needed)
  • npm run test:unit: Run unit tests only
  • npm run lint: Lint the codebase

Testing

The extension includes comprehensive test coverage:

Integration Tests

Integration tests run in a real VSCode instance with the extension activated and test against a sample workspace:

npm test

The integration tests verify:

  • Extension activation and command registration
  • MCP server HTTP endpoints
  • Symbol search (workspace and document-level)
  • Find references functionality
  • Go to definition/type/implementation
  • Rename symbol operations

Unit Tests

Unit tests verify module structure and imports:

npm run test:unit

Test Workspace

The test suite includes a sample workspace with TypeScript and C# files to test LSP features. See src/test/README.md for detailed testing documentation.

Troubleshooting

Extension Not Loading

  1. Check that the extension is installed: code --list-extensions | grep vscode-lsp-mcp
  2. Check the VSCode Output panel (View → Output) and select "Extension Host" from the dropdown
  3. Look for any error messages related to "vscode-lsp-mcp"

MCP Server Not Connecting

  1. Check VSCode notification to see which port the server started on (should appear when VSCode loads)
  2. Verify the URL in your Claude Code MCP configuration matches the server port (default: http://localhost:37140)
  3. Test if the server is running: curl http://localhost:37140/
  4. Check for port conflicts - try changing the port in VSCode settings if the default is already in use
  5. Try restarting VSCode and Claude Code

No Symbols Found

Some LSP features depend on the language server being active for the file type. Make sure:

  1. The appropriate language extension is installed in VSCode
  2. The workspace is fully loaded
  3. The language server has finished indexing

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft