name: vscode-mcp-architecture description: VSCode MCP Bridge project architecture — current monorepo layout, IPC/EventDispatcher flow, per-workspace socket discovery, MCP/CLI adapters, tool filtering, and VSCode extension services. Consult this before non-trivial project changes, connection debugging, workspace_path reasoning, or onboarding to the codebase.
VSCode MCP Bridge Architecture
Use this skill to rebuild the current project shape before changing code. Prefer source files over this summary when they disagree.
Mission
VSCode MCP lets MCP clients and shell-based agents use live VSCode context: diagnostics, LSP navigation, references, workspace rename, file opening, and selected VSCode commands. The project optimizes agent workflows that would otherwise run slower tsc, eslint, or build commands for every check.
Package Map
MCP client
-> packages/vscode-mcp-server
-> packages/vscode-mcp-core
-> packages/vscode-mcp-ipc
-> per-workspace socket
-> packages/vscode-mcp-bridge
-> VSCode API
Shell agent
-> packages/vscode-mcp-cli
-> packages/vscode-mcp-core
-> packages/vscode-mcp-ipc
-> per-workspace socket
-> packages/vscode-mcp-bridge
-> VSCode API
vscode-mcp-ipc: zod schemas,EventMap, shared types,EventDispatcher, socket path generation.vscode-mcp-bridge: VSCode extension,SocketServer, service handlers, extension commands, terminal launcher.vscode-mcp-core: framework-agnosticToolDefinitions, output formatting, workspace discovery, tool-name constants.vscode-mcp-server: stdio MCP server, tool filtering,McpServer.registerTooladapter.vscode-mcp-cli:vscode-cli, commander subcommands generated from core tool definitions.
Runtime Flow
- MCP server or CLI obtains a core
ToolDefinitionfromgetAllTools({ clientVersion }). - The MCP adapter adds
workspace_pathfor tools withrequiresWorkspace: true; the CLI adds--workspaceand defaults it toprocess.cwd(). - The adapter validates params with the tool schema, then the core handler creates an
EventDispatcher, dispatches the camelCase IPC event, and returns human-readable text. EventDispatcherconnects to the socket derived fromworkspace_path.- The bridge
SocketServervalidates payload and result schemas, calls the registered service, and returns JSON. - The adapter surfaces handler text. Thrown handler errors become MCP
isErrorresponses or CLI stderr exits.
Workspace And Socket Rules
workspace_pathselects the VSCode window/socket. It must match the workspace folder reported bylist_workspacesor the extension activation log.- Do not pass a child project, package, or git submodule path unless VSCode itself is opened at that path. Keep
workspace_pathat the open workspace root and pass child paths through tool-specific params. - Socket names use
md5(workspacePath).slice(0, 8). - Current socket locations:
- macOS:
~/Library/Application Support/YuTengjing.vscode-mcp/vscode-mcp-<hash>.sock - Linux/Unix:
${XDG_DATA_HOME:-~/.local/share}/yutengjing-vscode-mcp/vscode-mcp-<hash>.sock - Windows:
\\.\pipe\vscode-mcp-<hash>
- macOS:
- The dispatcher tries the current app-data socket first and falls back to legacy
/tmp/vscode-mcp-<hash>.sockfor older extensions. list_workspacesis global (requiresWorkspace: false). Core discovers socket files, health-checks them, and may clean zombie sockets.- If no workspace folder is open, the bridge extension activates terminal launcher commands but does not start the socket server.
Current Tools
Tool names live in packages/vscode-mcp-core/src/constants.ts and core exports them from packages/vscode-mcp-core/src/tools/index.ts.
health_check: verify bridge connection and version compatibility.get_diagnostics: read VSCode diagnostics; empty__NOT_RECOMMEND__filePathsmeans git-modified files.get_symbol_lsp_info: combined hover, signature help, type definition, definition, and implementation lookup.get_references: references with optional usage context.execute_command: run arbitrary VSCode commands; treat as destructive unless proven safe.open_files: open files, optionally in background.rename_symbol: VSCode workspace rename.list_workspaces: discover connectable VSCode windows.
Adapter Details
- Server filtering is handled by
--enable-tools,--disable-tools,VSCODE_MCP_ENABLED_TOOLS, andVSCODE_MCP_DISABLED_TOOLS. - Filtering validates against
VscodeMcpToolName; adding a tool requires updating the enum as well asgetAllTools. - CLI auto-generates flat flags from each zod object schema. Tools with arrays of objects or other non-flat params must set
tool.cli.optionsandtool.cli.transform. - MCP and CLI should expose the same core handler text. Avoid formatting in server or CLI adapters.
Bridge Extension Notes
packages/vscode-mcp-bridge/src/extension.tsregisters socket services and VSCode commands.packages/vscode-mcp-bridge/src/services/*is the only layer that should call VSCode APIs for MCP tools.packages/vscode-mcp-bridge/src/terminal-launcher/*contributes terminal toolbar buttons from extension configuration. It is not an MCP tool.- Bridge service return values must pass IPC output schemas and be JSON-serializable. Convert VSCode objects before returning them.
Debugging Checklist
- Connection failure: run
vscode-cli list-workspacesor MCPlist_workspaces, then use the reportedworkspace_path. - Unknown method: check IPC
EventMap, bridgesocketServer.register, and coregetAllTools. - Tool hidden in MCP: check server enable/disable args/env vars and
VscodeMcpToolName. - Payload/result validation failure: inspect the zod schema in
packages/vscode-mcp-ipc/src/events/*and bridge service output. - Slow or noisy validation: prefer
vscode-cli get-diagnosticsfrom the open workspace root before broader package builds.