VS Code MCP Server
A Visual Studio Code extension (available on the Marketplace) that allows Claude and other MCP clients to code directly in VS Code! Inspired by Serena, but using VS Code's built-in capabilities. This is currently far simpler than Serena, but it works! Note that this extension uses the streamable HTTP API, not the SSE API.
This extension can allow for execution of shell commands. This means that there is a potential security risk, so use with caution, and ensure that you trust the MCP client that you are using and that the port is not exposed to anything. Authentication would help, but as the MCP authentication spec is still in flux, this has not been implemented for now.
PRs are welcome!
Demo Video
https://github.com/user-attachments/assets/20b87dfb-fc39-4710-a910-b9481dde1e90
Installation
- Install the extension from the Marketplace or clone this repository and run
npm install
andnpm run compile
to build it.
Claude Desktop Configuration
Claude Desktop can be configured to use this extension as an MCP server. To do this, your claude_desktop_config.json
file should look like this:
I also like to use this extension in a Claude project, as it allows me to specify additional instructions for Claude. I find the following prompt to work well:
This extension serves as a Model Context Protocol (MCP) server, exposing VS Code's filesystem and editing capabilities to MCP clients.
Features
The VS Code MCP Server extension implements an MCP-compliant server that allows AI models and other MCP clients to:
- List files and directories in your VS Code workspace
- Read file contents with encoding support and size limits
- Search for symbols across your workspace
- Get symbol definitions and hover information by line and symbol name
- Create new files using VS Code's WorkspaceEdit API
- Make line replacements in files
- Check for diagnostics (errors and warnings) in your workspace
- Execute shell commands in the integrated terminal with shell integration
- Toggle the server on and off via a status bar item
This extension enables AI assistants and other tools to interact with your VS Code workspace through the standardized MCP protocol.
How It Works
The extension creates an MCP server that:
- Runs locally on a configurable port (when enabled)
- Handles MCP protocol requests via HTTP
- Exposes VS Code's functionality as MCP tools
- Provides a status bar indicator showing server status, which can be clicked to toggle the server on/off
Supported MCP Tools
File Tools
- list_files_code: Lists files and directories in your workspace
- Parameters:
path
: The path to list files fromrecursive
(optional): Whether to list files recursively
- Parameters:
- read_file_code: Reads file contents
- Parameters:
path
: The path to the file to readencoding
(optional): File encoding (default: utf-8)maxCharacters
(optional): Maximum character count (default: 100,000)
- Parameters:
Edit Tools
- create_file_code: Creates a new file using VS Code's WorkspaceEdit API
- Parameters:
path
: The path to the file to createcontent
: The content to write to the fileoverwrite
(optional): Whether to overwrite if the file exists (default: false)ignoreIfExists
(optional): Whether to ignore if the file exists (default: false)
- Parameters:
- replace_lines_code: Replaces specific lines in a file
- Parameters:
path
: The path to the file to modifystartLine
: The start line number (0-based, inclusive)endLine
: The end line number (0-based, inclusive)content
: The new content to replace the lines withoriginalCode
: The original code for validation
- Parameters:
Diagnostics Tools
- get_diagnostics_code: Checks for warnings and errors in your workspace
- Parameters:
path
(optional): File path to check (if not provided, checks the entire workspace)severities
(optional): Array of severity levels to include (0=Error, 1=Warning, 2=Information, 3=Hint). Default: [0, 1]format
(optional): Output format ('text' or 'json'). Default: 'text'includeSource
(optional): Whether to include the diagnostic source. Default: true
This tool is particularly useful for:
- Code quality checks before committing changes
- Verifying fixes resolved all reported issues
- Identifying problems in specific files or the entire workspace
- Parameters:
Symbol Tools
- search_symbols_code: Searches for symbols across the workspace
- Parameters:
query
: The search query for symbol namesmaxResults
(optional): Maximum number of results to return (default: 10)
This tool is useful for:
- Finding definitions of symbols (functions, classes, variables, etc.) across the codebase
- Exploring project structure and organization
- Locating specific elements by name
- Parameters:
- get_symbol_definition_code: Gets definition information for a symbol in a file
- Parameters:
path
: The path to the file containing the symbolline
: The line number of the symbol (0-based)symbol
: The symbol name to look for on the specified line
This tool provides:
- Type information, documentation, and source details for symbols
- Code context showing the line where the symbol appears
- Symbol range information
It's particularly useful for:
- Understanding what a symbol represents without navigating away
- Checking function signatures, type definitions, or documentation
- Quick reference for APIs or library functions
- Parameters:
Shell Tools
- execute_shell_command_code: Executes a shell command in the VS Code integrated terminal with shell integration
- Parameters:
command
: The shell command to executecwd
(optional): Optional working directory for the command (default: '.')
This tool is useful for:
- Running CLI commands and build operations
- Executing git commands
- Performing any shell operations that require terminal access
- Getting command output for analysis and further processing
- Parameters:
Caveats/TODO
Currently, only one workspace is supported. The extension also only works locally, to avoid exposing your VS Code instance to any network you may be connected to.
Extension Settings
This extension contributes the following settings:
vscode-mcp-server.port
: The port number for the MCP server (default: 3000)
Using with MCP Clients
To connect MCP clients to this server, configure them to use:
Remember that you need to enable the server first by clicking on the status bar item!
Contributing
Contributions are welcome! Feel free to submit issues or pull requests.
License
You must be authenticated.
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
vscode-mcp-server