MCP Bridge
by frederick623
README.md
# MCP Bridge
Turns every VS Code window into an [MCP](https://modelcontextprotocol.io) server. Open several windows on
different projects and each one can inspect and act on the others, and external agents can reach any of them.
## How it works
- On startup each window starts an MCP server on `127.0.0.1` (Streamable HTTP, endpoint `/mcp`) with a random
port and a random bearer token.
- It writes `{id, port, token, name, workspaceFolders}` to `~/.vscode-mcp-bridge/instances/<id>.json`
(directory mode `0700`, files `0600`) and removes the file when the window closes. Entries of crashed
windows are pruned automatically.
- Every window watches that directory and offers **the other windows** as MCP servers to its own chat / agent
mode (`VS Code: <workspace name>`), so an agent in window A can use window B's tools directly.
- Every server also has `list_instances` and `call_instance`, so a client connected to one window can reach
all of them.
The status bar shows `MCP :<port>`; click it to see the running windows.
## Tools
| Tool | Purpose |
| --- | --- |
| `get_instance_info`, `list_instances` | Identify this window / all running windows |
| `call_instance` | Run a tool in another window (omit `tool` to list that window's tools) |
| `show_message` | Show a notification to the user of the window |
| `list_files`, `read_file`, `search_text` | Explore the workspace (reads include unsaved editor changes) |
| `get_diagnostics` | Problems reported by the window's language servers and linters |
| `get_editor_state`, `open_file` | See / change what the user is looking at |
| `workspace_symbols`, `document_symbols`, `go_to_definition`, `find_references`, `get_hover` | Language intelligence |
| `write_file`, `edit_file` | Modify files (setting `mcpBridge.enableWriteTools`, on by default) |
| `run_terminal_command` | Run a shell command in the integrated terminal (`mcpBridge.enableTerminalTool`, **off** by default) |
| `execute_vscode_command` | Run any VS Code command (`mcpBridge.enableCommandTool`, **off** by default) |
File tools only accept paths inside the window's workspace folders.
## Connecting external clients
Run **MCP Bridge: Copy Connection Config** in the window you want to expose:
- **stdio proxy** (recommended) – a config that launches `out/stdioProxy.js --workspace <folder>`. The proxy
looks the window up in the registry for every message, so the config survives VS Code restarts:
```json
{ "mcpServers": { "vscode-myproject": { "command": "node", "args": ["<extension>/out/stdioProxy.js", "--workspace", "/path/to/myproject"] } } }
```
Without arguments the proxy picks the window whose workspace contains the current directory, or the only
running window. `--instance <id-or-name>` selects one explicitly.
- **HTTP** – the direct URL plus `Authorization: Bearer …` header. It contains a secret and changes each time
the window restarts (set `mcpBridge.port` for a fixed port).
## Settings
| Setting | Default | |
| --- | --- | --- |
| `mcpBridge.port` | `0` | Fixed port for this window; `0` = any free port |
| `mcpBridge.exposePeersToChat` | `true` | Offer other windows as MCP servers to this window's chat |
| `mcpBridge.enableWriteTools` | `true` | Expose `write_file` / `edit_file` |
| `mcpBridge.enableTerminalTool` | `false` | Expose `run_terminal_command` |
| `mcpBridge.enableCommandTool` | `false` | Expose `execute_vscode_command` |
The three `enable*` settings are ignored when they come from an untrusted workspace.
## Security
The server listens on loopback only, requires the bearer token and rejects browser origins. Anyone who can read
`~/.vscode-mcp-bridge` (i.e. your user account) can drive every window, including the tools you enabled, so
keep the terminal and command tools off unless you need them.
## Development
```sh
npm install
npm test # compiles and runs the unit tests
npm run package # builds the .vsix
```
Press F5 to launch an Extension Development Host. Requires VS Code 1.101 or newer.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues