Skip to content
Back to search

vscode-mcp-server

MCP server to expose VS Code editing features to an LLM for AI coding

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/juehang--vscode-mcp-server/badge.svg)](/listings/juehang--vscode-mcp-server)

HTML

<a href="/listings/juehang--vscode-mcp-server"><img src="/api/listings/juehang--vscode-mcp-server/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. Install the extension from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=JuehangQin.vscode-mcp-server) or clone this repository and run `npm install` and `npm run compile` to build it.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 263 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # VS Code MCP Server
  2. A Visual Studio Code extension (available on the [Marketplace](https://marketplace.visualstudio.com/items?itemName=JuehangQin.vscode-mcp-server)) that allows Claude and other MCP clients to code directly in VS Code! Inspired by [Serena](https://github.com/oraios/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.
  3. 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.
  4. PRs are welcome!
  5. ## Demo Video
  6. https://github.com/user-attachments/assets/20b87dfb-fc39-4710-a910-b9481dde1e90
  7. ## Installation
  8. 1. Install the extension from the [Marketplace](https://marketplace.visualstudio.com/items?itemName=JuehangQin.vscode-mcp-server) or clone this repository and run `npm install` and `npm run compile` to build it.
  9. ## Claude Desktop Configuration
  10. 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:
  11. ```
  12. {
  13. "mcpServers": {
  14. "vscode-mcp-server": {
  15. "command": "npx",
  16. "args": ["mcp-remote@next", "http://localhost:3000/mcp"]
  17. }
  18. }
  19. }
  20. ```
  21. 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:
  22. ```
  23. You are working on an existing codebase, which you can access using your tools. These code tools interact with a VS Code workspace.
  24. WORKFLOW ESSENTIALS:
  25. 1. Always start exploration with list_files_code on root directory (.) first
  26. 2. CRITICAL: Run get_diagnostics_code after EVERY set of code changes before completing tasks
  27. 3. For small edits (≤10 lines): use replace_lines_code with exact original content
  28. 4. For large changes, new files, or uncertain content: use create_file_code with overwrite=true
  29. EXPLORATION STRATEGY:
  30. - Start: list_files_code with path='.' (never recursive on root)
  31. - Understand structure: read key files like package.json, README, main entry points
  32. - Find symbols: use search_symbols_code for functions/classes, get_document_symbols_code for file overviews
  33. - Before editing: read_file_code the target file to understand current content
  34. EDITING BEST PRACTICES:
  35. - Small modifications: replace_lines_code (requires exact original content match)
  36. - If replace_lines_code fails: read_file_code the target lines, then retry with correct content
  37. - Large changes: create_file_code with overwrite=true is more reliable
  38. - After any changes: get_diagnostics_code to check for errors
  39. PLANNING REQUIREMENTS:
  40. Before making code modifications, present a comprehensive plan including:
  41. - Confidence level (1-10) and reasoning
  42. - Specific tools you'll use and why
  43. - Files you'll modify and approach (small edits vs complete rewrites)
  44. - How you'll verify the changes work (diagnostics, testing, etc.)
  45. ERROR HANDLING:
  46. - Let errors happen naturally - don't add unnecessary try/catch blocks
  47. - For tool failures: follow the specific recovery guidance in each tool's description
  48. - If uncertain about file content: use read_file_code to verify before making changes
  49. APPROVAL PROCESS:
  50. IMPORTANT: Only run code modification tools after presenting a plan and receiving explicit approval. Each change requires separate approval.
  51. Do not add tests unless specifically requested. If you believe testing is important, explain why and let the user decide.
  52. ```
  53. For context efficiency when exploring codebases, consider adding this to your CLAUDE.md:
  54. ```
  55. ## VS Code Symbol Tools for Context Efficiency
  56. Use VS Code symbol tools to reduce context consumption:
  57. - `get_document_symbols_code` for file structure overview instead of reading entire files
  58. - `search_symbols_code` to find symbols by name across the project
  59. - `get_symbol_definition_code` for type info and docs without full file context
  60. - Workflow: get outline → search symbols → get definitions → read implementation only when needed
  61. ```
  62. This extension serves as a Model Context Protocol (MCP) server, exposing VS Code's filesystem and editing capabilities to MCP clients.
  63. ## Features
  64. The VS Code MCP Server extension implements an MCP-compliant server that allows AI models and other MCP clients to:
  65. - **List files and directories** in your VS Code workspace
  66. - **Read file contents** with encoding support and size limits
  67. - **Move files and directories** with proper refactoring support for imports
  68. - **Rename files and directories** with automatic reference updates
  69. - **Copy files** to new locations (files only, not directories)
  70. - **Search for symbols** across your workspace
  71. - **Get symbol definitions** and hover information by line and symbol name
  72. - **Create new files** using VS Code's WorkspaceEdit API
  73. - **Make line replacements** in files
  74. - **Check for diagnostics** (errors and warnings) in your workspace
  75. - **Execute shell commands** in the integrated terminal with shell integration
  76. - **Toggle the server** on and off via a status bar item
  77. This extension enables AI assistants and other tools to interact with your VS Code workspace through the standardized MCP protocol.
  78. ## How It Works
  79. The extension creates an MCP server that:
  80. 1. Runs locally on a configurable port (when enabled)
  81. 2. Handles MCP protocol requests via HTTP
  82. 3. Exposes VS Code's functionality as MCP tools
  83. 4. Provides a status bar indicator showing server status, which can be clicked to toggle the server on/off
  84. ## Supported MCP Tools
  85. ### File Tools
  86. - **list_files_code**: Lists files and directories in your workspace
  87. - Parameters:
  88. - `path`: The path to list files from
  89. - `recursive` (optional): Whether to list files recursively
  90. - **read_file_code**: Reads file contents
  91. - Parameters:
  92. - `path`: The path to the file to read
  93. - `encoding` (optional): File encoding (default: utf-8)
  94. - `maxCharacters` (optional): Maximum character count (default: 100,000)
  95. - **move_file_code**: Moves a file or directory to a new location using VS Code's WorkspaceEdit API
  96. - Parameters:
  97. - `sourcePath`: The current path of the file or directory to move
  98. - `targetPath`: The new path where the file or directory should be moved to
  99. - `overwrite` (optional): Whether to overwrite if target already exists (default: false)
  100. - **rename_file_code**: Renames a file or directory using VS Code's WorkspaceEdit API
  101. - Parameters:
  102. - `filePath`: The current path of the file or directory to rename
  103. - `newName`: The new name for the file or directory
  104. - `overwrite` (optional): Whether to overwrite if a file with the new name already exists (default: false)
  105. - **copy_file_code**: Copies a file to a new location using VS Code's file system API
  106. - Parameters:
  107. - `sourcePath`: The path of the file to copy
  108. - `targetPath`: The path where the copy should be created
  109. - `overwrite` (optional): Whether to overwrite if target already exists (default: false)
  110. ### Edit Tools
  111. - **create_file_code**: Creates a new file using VS Code's WorkspaceEdit API
  112. - Parameters:
  113. - `path`: The path to the file to create
  114. - `content`: The content to write to the file
  115. - `overwrite` (optional): Whether to overwrite if the file exists (default: false)
  116. - `ignoreIfExists` (optional): Whether to ignore if the file exists (default: false)
  117. - **replace_lines_code**: Replaces specific lines in a file
  118. - Parameters:
  119. - `path`: The path to the file to modify
  120. - `startLine`: The start line number (1-based, inclusive)
  121. - `endLine`: The end line number (1-based, inclusive)
  122. - `content`: The new content to replace the lines with
  123. - `originalCode`: The original code for validation
  124. ### Diagnostics Tools
  125. - **get_diagnostics_code**: Checks for warnings and errors in your workspace
  126. - Parameters:
  127. - `path` (optional): File path to check (if not provided, checks the entire workspace)
  128. - `severities` (optional): Array of severity levels to include (0=Error, 1=Warning, 2=Information, 3=Hint). Default: [0, 1]
  129. - `format` (optional): Output format ('text' or 'json'). Default: 'text'
  130. - `includeSource` (optional): Whether to include the diagnostic source. Default: true
  131. This tool is particularly useful for:
  132. - Code quality checks before committing changes
  133. - Verifying fixes resolved all reported issues
  134. - Identifying problems in specific files or the entire workspace
  135. ### Symbol Tools
  136. - **search_symbols_code**: Searches for symbols across the workspace
  137. - Parameters:
  138. - `query`: The search query for symbol names
  139. - `maxResults` (optional): Maximum number of results to return (default: 10)
  140. This tool is useful for:
  141. - Finding definitions of symbols (functions, classes, variables, etc.) across the codebase
  142. - Exploring project structure and organization
  143. - Locating specific elements by name
  144. - **get_symbol_definition_code**: Gets definition information for a symbol in a file
  145. - Parameters:
  146. - `path`: The path to the file containing the symbol
  147. - `line`: The line number of the symbol
  148. - `symbol`: The symbol name to look for on the specified line
  149. This tool provides:
  150. - Type information, documentation, and source details for symbols
  151. - Code context showing the line where the symbol appears
  152. - Symbol range information
  153. It's particularly useful for:
  154. - Understanding what a symbol represents without navigating away
  155. - Checking function signatures, type definitions, or documentation
  156. - Quick reference for APIs or library functions
  157. - **get_document_symbols_code**: Gets an outline of all symbols in a file, showing the hierarchical structure
  158. - Parameters:
  159. - `path`: The path to the file to analyze (relative to workspace)
  160. - `maxDepth` (optional): Maximum nesting depth to display
  161. This tool provides:
  162. - Complete symbol tree for a document (similar to VS Code's Outline view)
  163. - Hierarchical structure showing classes, functions, methods, variables, etc.
  164. - Position information and symbol kinds for each symbol
  165. - Summary statistics by symbol type
  166. It's particularly useful for:
  167. - Understanding file structure and organization at a glance
  168. - Getting an overview of all symbols in a document
  169. - Analyzing code architecture and relationships
  170. - Finding all symbols of specific types within a file
  171. ### Shell Tools
  172. - **execute_shell_command_code**: Executes a shell command in the VS Code integrated terminal with shell integration
  173. - Parameters:
  174. - `command`: The shell command to execute
  175. - `cwd` (optional): Optional working directory for the command (default: '.')
  176. This tool is useful for:
  177. - Running CLI commands and build operations
  178. - Executing git commands
  179. - Performing any shell operations that require terminal access
  180. - Getting command output for analysis and further processing
  181. ## Caveats/TODO
  182. 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.
  183. ## Extension Settings
  184. * `vscode-mcp-server.port`: The port number for the MCP server (default: 3000)
  185. * `vscode-mcp-server.host`: Host address for the MCP server (default: 127.0.0.1)
  186. * `vscode-mcp-server.defaultEnabled`: Whether the MCP server should be enabled by default on VS Code startup
  187. * `vscode-mcp-server.enabledTools`: Configure which tool categories are enabled (file, edit, shell, diagnostics, symbol)
  188. **Selective Tool Configuration**: Useful for coding agents that already have certain capabilities. For example, with Claude Code you might disable file/edit tools and only enable symbol tools to add VS Code-specific symbol searching without tool duplication.
  189. ## Using with MCP Clients
  190. To connect MCP clients to this server, configure them to use:
  191. ```
  192. http://localhost:3000/mcp
  193. ```
  194. Or if you've configured a custom host:
  195. ```
  196. http://[your-host]:3000/mcp
  197. ```
  198. Remember that you need to enable the server first by clicking on the status bar item!
  199. ## Contributing
  200. Contributions are welcome! Feel free to submit issues or pull requests.
  201. ## License
  202. [MIT](LICENSE)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.