Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Editor Context MCP ServerNew to Visual Studio Code? Get it now.
Editor Context MCP Server

Editor Context MCP Server

Seegnify

|
19 installs
| (0) | Free
Exposes VS Code editor context (active file, selection, visible lines) via MCP
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Editor Context MCP Server - VS Code Extension

This VS Code extension exposes editor context (active file, selection, visible lines) to any MCP client (e.g. a coding agent) via an MCP (Model Context Protocol) server.

Features

  • Active File: Full path of the currently open file
  • Selection: Current text selection with line/column positions
  • Visible Ranges: Currently visible line ranges in the editor
  • Language ID: Programming language of the active file
  • On-Demand Fetching: Returns current editor state when requested
  • Notebook Support: Supports Jupyter notebooks with cell selection and visible ranges

Architecture

┌────────────────────────────┐              ┌──────────────────────────┐
│   VS Code Extension        │              │   A coding agent         │
│   (editor context)         │              │   (e.g. opencode)        │
│  ┌──────────────────────┐  │              │  ┌────────────────────┐  │
│  │  MCP Server          │  │              │  │  MCP Client        │  │
│  │  (mcp-server.ts)     │  │              │  │                    │  │
│  │                      │──┼── MCP API ───┼─►│  • File path       │  │
│  │  • HTTP server       │  │              │  │  • Language ID     │  │
│  │  • getEditorContext  │  │              │  │  • Selected text   │  │
│  │  • /mcp endpoint     │  │              │  │  • Lines range     │  │
│  └──────────────────────┘  │              │  └────────────────────┘  │
└────────────────────────────┘              └──────────────────────────┘

Prerequisites

  • VS Code 1.85.0+
  • NVM (Node Version Manager)
  • An MCP client (e.g., opencode CLI)

Build & Install

1. Setup Build Environment

cd vscode-context-mcp
nvm install 20
npm install

This compiles TypeScript to dist/ folder.

2. Build and Package the Extension (optional)

To create an installable .vsix file:

bash build.sh

This creates VSIX estension package.

3. Install the Extension

From built .vsix file:

bash install.sh

From source (development):

code --extension-development-host .

4. Open VS Code

The extension auto-activates when VS Code starts. You should see output in the Developer Tools console:

VSCode Context MCP server started on port <port>
VSCode Context MCP: MCP server running at http://127.0.0.1:<port>

Configure Your MCP Client

opencode

Add the MCP server to your opencode config (opencode.json):

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "vscode-context-mcp": {
      "type": "remote",
      "url": "http://127.0.0.1:9876/mcp"
    }
  }
}

Other MCP Clients

Configure your MCP client to connect to http://127.0.0.1:9876.

Configuration

Port (default: 9876)

Change via VS Code Settings:

{
  "vscodeContextMcp.port": 9876
}

Lock File Location

The extension writes connection info to:

~/.local/share/vscode-context-mcp/ide/<port>.lock

MCP Protocol

The extension implements the following MCP methods:

  • initialize - Initialize MCP session
  • tools/list - List available tools
  • tools/call - Call a tool
  • resources/list - List available resources
  • resources/read - Read editor://context resource

Tool: getEditorContext

Returns an EditorContext object with type and context:

  • type: "editor" | "notebook" | null
  • context: EditorState | NotebookState | null

Input Schema:

{}

Output - Text Editor:

{
  "type": "editor",
  "context": {
    "activeFile": "/path/to/file.ts",
    "selection": {
      "startLine": 10,
      "startColumn": 1,
      "endLine": 20,
      "endColumn": 5,
      "text": "selected text..."
    },
    "visibleRanges": [
      { "startLine": 1, "startColumn": 1, "endLine": 50, "endColumn": 1 }
    ],
    "languageId": "typescript"
  }
}

Output - Notebook:

{
  "type": "notebook",
  "context": {
    "notebookUri": "/path/to/notebook.ipynb",
    "notebookType": "jupyter-notebook",
    "selection": {
      "startLine": 10,
      "startColumn": 1,
      "endLine": 20,
      "endColumn": 5,
      "text": "selected text..."
    },
    "cellRange": {
      "startCell": 1,
      "endCell": 3
    },
    "visibleRanges": [
      { "startCell": 1, "endCell": 10 }
    ],
    "cellCount": 5,
    "languageId": "python"
  }
}

Output - No Active Editor:

{
  "type": null,
  "context": null
}

Resource: editor://context

Returns the same data as getEditorContext in JSON format.

Troubleshooting

Extension not starting?

  • Check VS Code Developer Tools (Help > Toggle Developer Tools) for logs
  • Ensure the extension is installed: code --list-extensions

Client can't connect?

  • Verify the MCP server is running in VS Code output
  • Check the port matches in both VS Code settings and your client config
  • Check for port conflicts: lsof -i :9876

Port conflicts?

  • Change the port in VS Code settings: "vscodeContextMcp.port": 9877

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft