
VSC MCP
STDIOMCP server exposing Language Server Protocol functionality as tools for AI code interaction
MCP server exposing Language Server Protocol functionality as tools for AI code interaction
This project provides tools that expose Language Server Protocol (LSP) functionality as MCP (Model Context Protocol) tools. It enables AI clients to programmatically analyze and edit code through standardized MCP tool calls.
It started as a simple project focused on coding only with TypeScript, then evolved to a full-featured MCP server that supports any language supported by VS Code.
Full details about latest changes and migration to headless VC Code can be found here
VSC-MCP can run in two modes:
3000
(IDE UI) and 5007
(LSP bridge).cd
into it.bun install
PROJECT_PATH=/path/to/your/project docker-compose up
settings.json
)
{ "mcpServers": { "vsc-mcp": { "command": "bun", "args": ["<vsc_mcp_cloned_dir>/src/index.ts"], "env": { "USE_VSCODE_LSP": "true", "LOG_DIR": "<vsc_mcp_cloned_dir>/logs", "ALLOWED_DIRECTORIES": "/path/to/your/project" } } } }
Variable | Purpose |
---|---|
USE_VSCODE_LSP | Set to true to enable Docker/VS Code LSP mode. MCP will forward LSP requests to VS Code (port 5007) instead of spawning a local language server. |
ALLOWED_DIRECTORIES | Restricts direct-file manipulation to the specified directories. |
LOG_DIR | Where MCP writes logs for debugging. |
Note: By default,
USE_VSCODE_LSP
isfalse
(standalone mode). Set it totrue
to use Docker/VS Code LSP integration.
For now the best workflow is to use Claude Desktop as AI Client, it support MCP servers and it provide a monthly plan for 20$/month, and by using the VSC-MCP tools, we can "chat" and work with our codebase.
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
Add the following configurations to the mcp_servers
section of the config file:
{ "mcpServers": { "repomix": { "command": "npx", "args": [ "-y", "repomix", "--mcp" ] }, "vsc-mcp": { "command": "bun", "args": [ "<vsc_mcp_cloned_dir>/src/index.ts" ], "env": { "USE_VSCODE_LSP": "true", "LOG_DIR": "<vsc_mcp_cloned_dir>/logs", "ALLOWED_DIRECTORIES": "/path/to/your/project" } } } }
We suggest to add the repomix
mcp server dependency, to know why, you can read this blog post.
Replace <vsc_mcp_cloned_dir>
with the actual path to your vsc-mcp cloned directory.
When we start docker we need to specify the workspace directory.
PROJECT_PATH=/path/to/your/project docker-compose up
VSC-MCP tools will only be able to access files in the workspace directory.
The VSC-MCP tools include a security feature to restrict OS file operations (read and write files on disk) to specific directories:
ALLOWED_DIRECTORIES: An environment variable that specifies a comma-separated list of directories where file operations are permitted.
Example:
ALLOWED_DIRECTORIES=/home/user/projects,/tmp/workspace
If this environment variable is not set, operations default to the current working directory only.
All file operations (read, write, edit) will check if the target path is within the allowed directories.
Attempting to access files outside allowed directories will result in an "Access denied" error.
This feature helps prevent unauthorized access to sensitive files and directories on the system.
Currently, the following tools are available:
edit_symbol
: Edits a symbol (function, class, method, etc.) by name and type in a given file using LSP.
read_symbol
: Reads a symbol (function, class, method, etc.) by name and type in a given file using LSP.
read_file
: Reads the content of a file.
write_file
: Creates a new file or overwrites an existing file with the provided content.
search_replace_file
: Searches for content in a file and replaces it with new content.
get_errors
: Fetches code errors and issues for a specific file using the LSP textDocument/diagnostic API.
find_references
: Finds all references to a symbol (function, class, etc.) by name and type in a given file using LSP.