vscode-editor-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@vscode-editor-mcpWhat file and selection do I have open in VS Code?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
Related MCP server: Code MCP Server
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:
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.MCP server (
src/server.ts) — a standalone stdio process that reads the JSON file and exposes theget_selectiontool 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
Install
Windows (PowerShell)
./install.ps1The 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.vsixConfigure 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 changeLicense
MIT
Available Tools
1 toolget_selectionGet VS Code editor selectionA
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.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of behavioral disclosure. It notes 1-based line/character numbers, which is useful, but does not mention behavior when no file is open or no selection exists, nor whether it is read-only. Partially transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, well-structured sentence that front-loads the key information (what is returned) and adds the 1-based detail without fluff. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema exists, so the description must explain return values. It does so at a high level but lacks the exact structure (e.g., object fields, array format) needed for an agent to reliably consume the result. Edge cases like 'no active editor' are also unaddressed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the schema fully covers parameter semantics. Baseline is 4, and the description adds no misleading or unnecessary parameter information.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description explicitly states the tool returns the file name/path and line ranges of selections, with a specific verb ('Returns') and resource ('VS Code's active editor'). It is unambiguous and distinct from potential sibling tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage (when you need the current editor selection) but provides no explicit when-to-use statement, alternatives, or exclusions. For a simple getter with no siblings, the context is clear but not fully explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
With only one tool, there is no possibility of overlap or confusion. get_selection has a clearly distinct purpose.
The single tool follows the clear verb_noun pattern (get_selection), and since there are no other tools, there are no inconsistencies.
A single tool is far too few for an editor MCP, which would normally require operations like opening files, editing text, or managing tabs. This feels severely under-scoped.
The tool surface is severely incomplete: it only reads the current selection and provides no way to modify files or interact with the editor in other ways, making most editor workflows impossible.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Read and write your Fresh Jots notes from Claude, Cursor, and any MCP client.
Share one project context across ChatGPT, Claude, Telegram and any MCP client.
The OpenRouter MCP server plugs OpenRouter into the AI tools you already use. Once connected, your assistant can pull live OpenRouter data (models, prices, your credits, rankings, and docs) and send quick test messages, all without leaving your editor.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA VS Code extension provides a MCP server that exposes Roslyn language features. It enables tools like find usages, go to definition, quick info, etc.224AGPL 3.0
- AlicenseCqualityFmaintenanceEnables AI agents and assistants like Goose or Claude to interact with VS Code through the Model Context Protocol.763275Apache 2.0
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol (MCP) server that provides VSCode context and filesystem operations for AI assistants.9
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with VS Code's language server protocol features (definitions, references, diagnostics) and debugger (breakpoints, stepping, variable inspection) via an MCP server.161MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/user-ic/vscode_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server