Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>OpenCode to VSCode BridgeNew to Visual Studio Code? Get it now.
OpenCode to VSCode Bridge

OpenCode to VSCode Bridge

Vlado Vrbanec

|
23 installs
| (0) | Free
VSCode addon for OpenCode AI agent. Editor state, command execution, file operations via HTTP/MCP bridge. Agent sees tabs, cursor, selection, edits with undo support. 18 MCP tools, 15 slash commands.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

OpenCode to VSCode Bridge

OpenCode to VSCode Bridge

Author: Vlado Vrbanec — vlado.vrbanec@mvv.hr

Purpose: Agent awareness of the user's visual working environment. The AI agent can see which tabs are open, cursor position, selection range, dirty (unsaved) state per file, and manipulate the editor directly. This lets the agent reason about what the user sees and work contextually within their editor.

🔧 From version 0.0.9, the bridge provides full active debugger control via VSCode's Debug Adapter Protocol (DAP). The agent can start and stop debug sessions, set breakpoints, step through code, inspect variables at runtime, evaluate expressions in the current execution context, and read program output — all through 23 dedicated debug tools. Instead of passively reasoning about bugs from source code alone, the agent can now observe the program's actual runtime state: variable values, call stacks, thread status, and live output. This transforms debugging from static analysis into an interactive diagnostic loop where the agent correlates source code with real execution behavior, dramatically improving its ability to identify root causes.

Works in terminal or GUI client applications. Also works with any VSCode sidebar extension, or HTTP connected application. Agent can call 21 base MCP tools + 23 debug + 9 LSP + 3 Decorate tools (all loaded on demand) + 15 slash commands.

Plugin supports up to 5 open VSCode sessions simultaneously, with automatic switching when changing sessions.

Bridge is pure Node.js — likely works on macOS and Linux, but only tested on Windows.

Components

Component Location
VSCode Extension HTTP bridge server inside VSCode
HTTP Bridge Server Loads automatically and is available on first available port between 49152 and 49157
OpenCode Plugin Plugin is automatically installed when VSCode extension is installed.
Is automatically reinstalled if version is changed.
When OpenCode is loaded, connect to port if session folder is the same as in VSCode workspace.
Connect to port of another VSCode instance if OpenCode session is changed.
This way one OpenCode GUI or terminal can be connected to multiple VSCode instances.

Terminal or TUI Electron app ?

  • OpenCode can run as a terminal application (CLI) or as a GUI application built with Electron/Tauri.

  • We recommend using the GUI for better user experience.

  • GUI can run multiple tabs, multiple sessions, and multiple workspaces.

  • Reconnections to VSCode session with the same workspace is automatically handled.

  • Download: https://opencode.ai/download/stable/windows-x64-nsis

  • And another excellent : https://openchamber.dev

Architecture

Component Role
VSCode extension HTTP server inside VSCode — receives requests, interacts with editor, runs debug sessions
OpenCode plugin Connects to the extension, injects slash commands, registers MCP tools
MCP server Exposes 51 tools to the agent via Model Context Protocol (spawned automatically by OpenCode)
Connection localhost:PORT (127.0.0.1 only, ports 49152-49157)
Automatic selection, connection, and reconnection via discovery files

Base MCP tools (always loaded — 21)

health, info, version, selection, source, open, command, commands, tool_topic, edit_range, insert_at_line, edit_selection, clear_marks, edit_file, edit_create, files, workspace_files, symbols, search, output_read, output_list

Debug MCP tools (loaded on demand via tool_topic("debug") — 23)

debug_configurations, debug_prerequisites, debug_build, debug_start, debug_stop, debug_pause, debug_session, debug_overview, debug_thread_list, debug_state, debug_callstack, debug_where, debug_breakpoints, debug_exceptions, debug_continue, debug_step_over, debug_step_into, debug_step_out, debug_variables, debug_evaluate, debug_console_write, debug_set_variable, debug_console

ℹ️ Debug tools are not loaded into the agent's context by default. The agent calls tool_topic("debug") to register them on demand, saving context tokens when debugging is not needed.

LSP MCP tools (loaded on demand via tool_topic("lsp") — 9)

lsp_diagnostics, lsp_definition, lsp_references, lsp_hover, lsp_rename, lsp_document_symbols, lsp_completion, lsp_code_actions, lsp_apply_code_action

ℹ️ LSP tools provide semantic code analysis via the Language Server Protocol — definitions, references, diagnostics, type information. The agent calls tool_topic("lsp") to make them available. These are NOT loaded by default to save context tokens.

Decorate MCP tools (loaded on demand via tool_topic("decorate") — 3)

decorate_range, decorate_gutter, decorate_clear

ℹ️ Decorate tools let the agent paint visual markers in the editor WITHOUT modifying file content — color code regions, add colored gutter dots, and clear decorations. Unlike edit highlights, decorates do NOT auto-dismiss. The agent calls tool_topic("decorate") to make them available.

ℹ️ Tools are used by the AI agent, not the user. For file reading and editing, the agent can use OpenCode's built-in tools or MCP tools.

ℹ️ Agent automatically discovers tool endpoints and parameters via MCP protocol.

Debugging

The bridge provides full debugger control via VSCode's Debug Adapter Protocol (DAP). The agent can:

Capability Tools
Session management debug_configurations, debug_prerequisites, debug_build, debug_start, debug_stop
Execution control debug_continue, debug_pause, debug_step_over, debug_step_into, debug_step_out
Breakpoints debug_breakpoints (add/remove/list/listActive), debug_exceptions (first-chance/unhandled)
State inspection debug_state, debug_overview, debug_session, debug_where, debug_thread_list, debug_callstack
Variables debug_variables, debug_evaluate, debug_console_write, debug_set_variable
Output debug_console (buffered, incremental), output_read, output_list

Debug workflow

  1. debug_prerequisites — check environment readiness (SDK, launch.json, project files)
  2. debug_build — build the project (uses tasks.json or falls back to dotnet build)
  3. debug_start — start a debug session from launch.json config
  4. Poll debug_state (with compact:true) until stopped:true
  5. debug_where — see file, line, and source around the stop location
  6. debug_variables / debug_evaluate — inspect variables and expressions
  7. debug_continue / debug_step_over — advance execution, then poll again

ℹ️ After debug_continue or step commands, the agent polls debug_state until stopped:true — execution is asynchronous.

ℹ️ When debugging a GUI/EXE application, the agent cannot click buttons in the app window. It tells the user explicitly what to do, then polls for breakpoints or output.

Language Server Protocol (LSP)

The bridge exposes VSCode's Language Server infrastructure to the agent — semantic code analysis without running the program. The agent calls tool_topic("lsp") once to load the LSP tools.

Capability Tool Description
Live diagnostics lsp_diagnostics(file) Errors, warnings, hints from the Language Server for a file
Go to definition lsp_definition(file, line, column) Where a symbol is declared
Find references lsp_references(file, line, column) All usages of a symbol (AST-level, not text match)
Type info lsp_hover(file, line, column) Type signature, documentation, parameters
Rename lsp_rename(file, line, column, newName) Safe rename across the entire workspace
Document symbols lsp_document_symbols(file) Hierarchical symbol tree (classes, functions, variables)
Completions lsp_completion(file, line, column) Autocomplete suggestions at a position
Code actions lsp_code_actions(file, startLine, endLine) List quick fixes and refactorings for a range
Apply code action lsp_apply_code_action(file, index, startLine, endLine) Apply a code action by index (undoable)

How LSP works in the bridge

Agent ──MCP──→ Plugin ──HTTP──→ Extension ──VSCode API──→ VSCode ──LSP/JSON-RPC──→ Language Server

The agent calls an LSP MCP tool (e.g. lsp_definition). The plugin forwards it via HTTP to the extension. The extension calls vscode.commands.executeCommand(...) with the target file URI and position. VSCode internally routes the request to the appropriate Language Server (tsserver, OmniSharp, Pylance, etc.) via LSP/JSON-RPC over stdio. The result travels back up the chain. The agent never communicates with the Language Server directly — only VSCode does.

ℹ️ LSP requires a VSCode extension for the language (TypeScript, C#, Python, etc.) — the bridge uses whatever Language Server is already active in VSCode.

ℹ️ lsp_diagnostics returns live errors from the Language Server — different from build/compile errors. Use it before debugging to catch type and syntax issues early.

Visual Decorations

The bridge lets the agent paint visual markers in the editor without changing file content. Unlike edit highlights (which auto-dismiss and are tied to edits), these decorations persist until explicitly cleared.

Tool What it does
decorate_range(file, startLine, endLine, color?, tooltip?) Paint a colored background on a range of lines
decorate_gutter(file, line, color?, tooltip?) Add a colored dot in the line-number gutter
decorate_clear(file?) Remove all decorations from a file (omit file to clear all)

Available colors: red, green, blue, yellow, purple, orange, cyan, pink, gray — or any CSS rgba/hsl/hex string.

ℹ️ The agent calls tool_topic("decorate") once to load these tools. Decorations survive editor tab switches and do NOT auto-dismiss.

Slash commands (from version 0.0.3)

Slash commands

User-facing shortcuts. Type /vsc........ in the OpenCode chat to run an editor-aware task. Registered by the plugin at startup — no configuration needed.

Command What it does

| /vsc | Signal the agent that the rest of the conversation relates to working with the VSCode editor | | /vscDebugTab | Debug the file open in the active VSCode editor tab | | /vscDebugSelection | Debug the code currently selected in the VSCode active editor | | /vscReviewTab | Code review of the file open in the active VSCode editor tab | | /vscReviewSelection | Code review of the selected code in the VSCode active editor | | /vscExplainTab | Explain what the file open in the active VSCode editor tab does | | /vscExplainSelection | Explain the code currently selected in the VSCode active editor | | /vscExplainProject | Explain current project and show prompt to save explanation to a file | | /vscFindUsages | Find all usages of the selected function/class/variable across the workspace | | /vscRefactorSelection | Refactor the selected code in the VSCode active editor | | /vscDocTab | Add documentation comments to the file open in the active VSCode editor tab | | /vscDocSelection | Add documentation comments to the selected code in the VSCode active editor | | /vscMapToContext | Map the project structure and key files for context | | /vscTranslateSelectionToEN | Translate the selected text in the VSCode active editor to English | | /vscTranslateTabToEN | Translate the entire file content in the VSCode active editor to English |

Definitions: inject/vsc-commands.json. Always loaded — no configuration needed.

Quick Install

ℹ️ If not installed from side panel:

Install from marketplace.

OpenCode to VSCode Bridge — VS Code Marketplace

OpenCode plugin setup (required)

The OpenCode plugin is automatically installed when you start the VSCode extension.

⚡ If OPENCODE is installed after extension, please reinstall VSCode extension.

Usage

When component is installed, start or restart opencode. The plugin automatically connects to the VSCode bridge when you open a workspace folder.

Ask the agent a few questions:

ℹ️ Doesn't need to be exact, agent will understand the context. ⚡ If agent is not aware of available tools, execute /vsc command to set editor context.

ℹ️ Instructions to the agent can be in any language, not just English; however, the agent will pick up context at the beginning of the session in English faster.

Agent will probably 'think' in English but will understand your language, and answer in your language.

⚡ If the agent doesn't immediately respond to editor context, start with "vsc" — it's a trigger word that anchors the conversation to the editor.

  • Which file is opened in editor?
  • What is the current cursor position?
  • What is the current selection?
  • What is the current line number?
  • What is the current column number?
  • What is the selected text?
  • Please debug file opened in editor.
  • ... and other questions

When the AI agent knows the context, we can ask without specifying the file name:

  • Check file for errors.
  • Insert "This text" at cursor position.
  • Please create comment for function MyExampleFunction.
  • Please check selected lines for errors.
  • Translate selected text to Italian

And other instructions in natural language.

Agent will automatically try to obey instructions. With time you will learn which instructions are more clear to the agent.

⚡If VSCode extension is not active, or used folder is not the same, agent will respond with an predefined error message.

Status Bar

The extension adds a status bar indicator at the bottom-right of VSCode: Taskbar icon Mouse over icon will display info about last Opencode connection: Info

Indicator Meaning
$(broadcast) OCB Bridge starting (no port yet)
$(broadcast) OCB: <port> Bridge active, listening on port
$(check) OCB: <port> Bridge active, connected to Opencode session
$(error) OCB Bridge failed to start

Click on the status bar item to open the Actions Menu:

Action What it does
$(terminal) Open Terminal Creates integrated terminal in workspace folder and runs opencode
$(lines) Clear all highlights When lines are changed or inserted by agent via tool line is highlighted.
Highlight can be cleared one by one or all with this menu option.
$(gear) Reset Settings to Defaults Restore default timeout and highlight values.
$(info) About Opens extension README

Configuration

Settings are available in VSCode Settings UI (Ctrl+, → search "OpenCode Bridge") or settings.json.

Setting Default Description
opencodeBridge.highlightSafetyMs 600000 (10 min) Auto-dismiss edit highlights after this many ms. Default is almost always functional — lower only if you want highlights to disappear faster.
opencodeBridge.httpTimeoutMs 5000 (5 s) HTTP request timeout for plugin-to-extension calls. Default is almost always functional — increase only on very slow machines or with very large files.
opencodeBridge.scanTimeoutMs 3000 (3 s) Port scan timeout for bridge discovery. Default is almost always functional — increase only if discovery is unreliable on slow networks.

To reset all settings to defaults: open the Actions Menu (click the status bar item) and choose Reset Settings to Defaults, or run command OpenCode Bridge: Reset Settings to Defaults from the Command Palette.

Changes take effect on the next OpenCode session (plugin reads config on startup).

Notes

  • Each OpenCode instance automatically pairs with VSCode running in the same workspace.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft