user-ic

VS Code Editor MCP

Community user-ic
Updated

VS Code Editor MCP

A VS Code extension that exposes the editor's active file and selection(s) to CLI-based LLM coding agents — such as OpenCode and Crush — through a Model Context Protocol (MCP) server.

Why

CLI coding agents run outside the editor and have no direct way to know what you're looking at in VS Code. This extension bridges that gap: it continuously publishes the active editor's file path, language, and selection(s) to a shared state file, and an MCP server exposes that state through the get_selection tool. Any MCP-compatible CLI client can connect to the server and incorporate the current editor context into its prompts, so the agent sees the same file and selection you do without you having to copy-paste paths or line ranges.

How it works

The extension and the MCP server run in separate processes and communicate through a shared JSON file (vscode-editor-mcp-state.json) in the OS temp directory:

  1. Extension (src/extension.ts) — runs inside VS Code, listens to editor events (active editor change, selection change), and writes the current state to the shared JSON file.
  2. MCP server (src/server.ts) — a standalone stdio process that reads the JSON file and exposes the get_selection tool to MCP clients.

Provided tool

get_selection

Returns the name and path of the file open in VS Code's active editor along with the line range(s) of the current selection(s). Line and character numbers are 1-based.

Prerequisites

  • Node.js ≥ 20
  • VS Code ≥ 1.100.0
  • The code CLI on your PATH (or specify another with -CodeCommand)

Install

Windows (PowerShell)

./install.ps1

The script installs dependencies, builds the TypeScript, packages a .vsix, and installs it into VS Code. Use -NoInstall to skip installing into VS Code, or -CodeCommand to target a different editor CLI (e.g. code-insiders, codium).

Manual

npm install
npm run build
npx @vscode/vsce package --allow-missing-repository
code --install-extension vscode-editor-mcp-0.1.0.vsix

Configure an MCP client

Point your MCP client at the packaged server. The server binary is out/server.js (also exposed as the vscode-editor-mcp-server bin entry).

Example client configuration (stdio transport):

{
  "mcpServers": {
    "vscode-editor-mcp": {
      "command": "node",
      "args": ["C:/source/vscode_mcp/out/server.js"]
    }
  }
}

Reload VS Code after installing so the extension starts writing editor state.

Commands

  • VS Code Editor MCP: Show Current Editor State — prints the active file name and selection count. Useful for verifying the extension is running.

Build

npm run build      # compile to out/
npm run watch      # recompile on change

License

MIT

MCP Server · Populars

MCP Server · New

    Bevel-Software

    hexis

    Git-backed skills, tools & context for AI agents

    Community Bevel-Software
    jonashertner

    OpenCaseLaw

    Open Swiss legal corpus + MCP server: 1M+ court decisions (1875–today), 21k laws, 10M-edge citation graph, 42 MCP tools. CC0 data, MIT code. Live at mcp.opencaselaw.ch

    Community jonashertner
    SystemCraftsman

    Strimzi Kafka CLI

    Command Line Interface for the Strimzi Kafka Operator

    Community SystemCraftsman
    DROOdotFOO

    Raxol

    Write one app, render it to a terminal, a browser, or as agent tools. The terminal for your Gundam.

    Community DROOdotFOO
    morluto

    REA: Reverse Engineer Anything

    Reverse engineer anything with agents, from app behavior down to native binaries.

    Community morluto