官方说明📇 🏠 - A MCP Server that allows AI such as Claude to read from the directory structure in a VS Code workspace, see problems picked up by linter(s) and the language server, read code files, and make edi
配置模板(请按你的客户端调整)
claude mcp add vscode-mcp-server -- npx -y vscode-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. Perfect for extending existing coding agents like Claude Code with VS Code-specific capabilities (symbol search, document outlines) without duplicating tools they already have. 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 1. Install the extension from the Marketplace or clone this repository and run npm install and npm 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: For context efficiency when exploring codebases, consider adding this to your CLAUDE.md: 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 - **Move files and directories** with proper refactoring support for imports - **Rename files and directories** with automatic reference updates - **Copy files** to new locations (files only, not directories) - **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: 1. Runs locally on a configurable port (when enabled) 2. Handles MCP protocol requests via HTTP 3. Exposes VS Code's functionality as MCP tools 4. 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 from - recursive (optional): Whether to list files recursively - **read_file_code**: Reads file contents - Parameters: - path: The path to the file to read - encoding (optional): File encoding (default: utf-8) - maxCharacters (optional): Maximum character count (default: 100,000) - **move_file_code**: Moves a file or directory to a new location using VS Code's WorkspaceEdit API - Parameters: - sourcePath: The current path of the file or directory to move - targetPath: The new path where the file or directory should be moved to - overwrite (optional): Whether to overwrite if target already exists (default: false)