VS Code MCP server

Exposes VS Code's filesystem, editing capabilities, symbol search, diagnostics, and terminal access as tools for AI-assisted coding tasks directly within your existing VS Code environment.
Back to servers
Provider
Qin Juehang
Release date
Apr 27, 2025
Language
TypeScript
Stats
121 stars

The VS Code MCP Server extension enables AI assistants like Claude to interact directly with your VS Code workspace through the Model Context Protocol (MCP). It allows AI models to access your files, make edits, execute commands, and more—all within your familiar VS Code environment.

Installation

You can install the VS Code MCP Server extension in two ways:

git clone https://github.com/juehang/vscode-mcp-server.git
cd vscode-mcp-server
npm install
npm run compile

Configuration

After installation, you can configure the port number through VS Code settings:

  • Default port: 3000
  • To change: Modify the vscode-mcp-server.port setting in your VS Code preferences

Using with Claude Desktop

To configure Claude Desktop to work with this extension:

  1. Create or edit your claude_desktop_config.json file with the following content:
{
  "mcpServers": {
    "vscode-mcp-server": {
        "command": "npx",
        "args": ["mcp-remote@next", "http://localhost:3000/mcp"]
    }
  }
}
  1. Enable the server by clicking the MCP Server status bar item in VS Code

Recommended Claude Project Prompt

For best results when using Claude with this extension, consider using this project prompt:

You are working on an existing codebase, which you can access using your tools. These code tools interact with a VS Code workspace.

Before running code tools that will make any modification to code, always present a comprehensive and detailed plan to the user, including your confidence level (out of 10). When planning, use your tools to explore the codebase so that you understand the context of the project. If you are not confident in your plan because you require more information, use your tools, such as web search, to look for this information or ask the user.

IMPORTANT: Only run code tools that will modify code after presenting such a plan to the user, and receiving explicit approval. Approval must be given each time; prior approval for a change does not imply that subsequent changes are approved.

Available MCP Tools

File Tools

List Files

list_files_code({
  path: "/path/to/directory",
  recursive: true  // optional, default is false
})

Read File Contents

read_file_code({
  path: "/path/to/file.txt",
  encoding: "utf-8",  // optional, default is utf-8
  maxCharacters: 100000  // optional, default is 100,000
})

Edit Tools

Create New File

create_file_code({
  path: "/path/to/new_file.txt",
  content: "File content goes here",
  overwrite: false,  // optional, default is false
  ignoreIfExists: false  // optional, default is false
})

Replace Lines in File

replace_lines_code({
  path: "/path/to/file.txt",
  startLine: 5,  // 0-based, inclusive
  endLine: 10,  // 0-based, inclusive
  content: "New content to replace lines 5-10",
  originalCode: "Original code for validation"
})

Diagnostics Tools

Get Workspace Diagnostics

get_diagnostics_code({
  path: "/path/to/file.txt",  // optional, checks entire workspace if omitted
  severities: [0, 1],  // optional, 0=Error, 1=Warning, 2=Information, 3=Hint
  format: "text",  // optional, 'text' or 'json'
  includeSource: true  // optional, whether to include diagnostic source
})

Symbol Tools

Search for Symbols

search_symbols_code({
  query: "functionName",
  maxResults: 10  // optional, default is 10
})

Get Symbol Definition

get_symbol_definition_code({
  path: "/path/to/file.js",
  line: 42,  // 0-based line number
  symbol: "functionName"
})

Shell Tools

Execute Shell Command

execute_shell_command_code({
  command: "git status",
  cwd: "."  // optional, working directory for the command
})

Security Considerations

This extension can execute shell commands, which presents potential security risks. Please ensure:

  • You trust the MCP client you're connecting
  • The server port isn't exposed beyond your local machine
  • You review any commands before they are executed

Usage Tips

  1. Enable/disable the server by clicking the status bar item
  2. The server URL for MCP clients is: http://localhost:3000/mcp (or your configured port)
  3. The extension only works with the local workspace and doesn't support remote connections
  4. Currently only supports a single workspace at a time

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later