A Visual Studio 2022 extension that implements the Claude Code IDE protocol — the same one the official Claude Code for VS Code extension uses — so the claude CLI can connect to Visual Studio and drive inline diffs, selection sharing, diagnostics lookup, and file navigation.
- Starts a local MCP server on
127.0.0.1:<random port>(WebSocket, JSON-RPC 2.0, MCP2024-11-05). - Writes a discovery lock file at
%USERPROFILE%\.claude\ide\<port>.locksoclaude /idediscovers "Visual Studio 2022" automatically. - Exposes 11 MCP tools:
get_workspace_folders,get_open_editors,get_current_selection,get_latest_selection,get_diagnostics,check_document_dirty,open_file,save_document,close_tab,close_all_diff_tabs, and the blockingopen_diffthat shows a native VS diff and waits for Accept/Reject. - Emits
selection_changedandat_mentionednotifications so Claude sees editor selections in real time. - Ships a tool window showing server status and a one-click "Start Claude in terminal" button that pre-wires the env vars.
- Visual Studio 2022 (17.0+) — Community, Professional, or Enterprise
- Visual Studio SDK workload (install via the VS Installer → "Visual Studio extension development")
- .NET Framework 4.7.2 targeting pack
- Claude Code CLI installed and on PATH (
npm i -g @anthropic-ai/claude-code)
- Open
ClaudeCodeVS.slnin Visual Studio 2022. - First build restores NuGet packages:
Microsoft.VisualStudio.SDK,Microsoft.VSSDK.BuildTools,Newtonsoft.Json. - Press F5 — this launches the Visual Studio Experimental Instance with the extension loaded.
- The packaged VSIX lands in
src\ClaudeCodeVS\bin\Debug\ClaudeCodeVS.vsix. Double-click to install into your normal Visual Studio.
- In the Experimental Instance, open any solution.
- Open
View → Other Windows → Claude Code(orTools → Open Claude Code Panel). The panel showsRunning+ a port number. - Confirm
%USERPROFILE%\.claude\ide\<port>.lockexists and contains JSON with"ideName": "Visual Studio 2022","transport": "ws", and anauthToken. - In an external terminal, run
claude. Then inside the chat:/ide. It should list Visual Studio 2022 and connect without an auth error. - Ask Claude: "list the files I have open" → it should invoke
get_open_editorsand return your tabs. - Select a block of code in the editor, press Ctrl+Alt+K → Claude receives
at_mentionedwith the selection. - Ask Claude to edit a file → a diff view opens. Press Ctrl+Alt+Y (Accept) to write the change, or Ctrl+Alt+N (Reject) to discard it.
- Close Visual Studio → confirm the lock file is deleted.
VsixPackage (AsyncPackage)
├─ IdeServices ───── DTE2, IVsTextManager, IVsDifferenceService, SVsErrorList
├─ SelectionTracker IVsTextManagerEvents → debounced selection_changed
├─ DiffCoordinator IVsDifferenceService.OpenComparisonWindow2 + TaskCompletionSource
├─ LockFileManager ~/.claude/ide/<port>.lock (atomic write, sweep stale)
├─ McpWebSocketServer HttpListener → AcceptWebSocketAsync on 127.0.0.1:<10000..65535>
│ x-claude-code-ide-authorization header → AuthToken.ConstantTimeEquals
├─ JsonRpcDispatcher initialize, tools/list, tools/call, ping
└─ ToolRegistry → 11 MCP tools under Protocol/Tools/
- The server only binds to
127.0.0.1, so it is unreachable from other machines. - Each VS session generates a fresh 48-byte random
authToken(base64url). Connections without thex-claude-code-ide-authorizationheader are rejected with HTTP 401. - Token comparison uses a constant-time check to prevent timing attacks (see CVE-2025-52882).
- The lock file is readable only by the user's profile (NTFS default ACLs).
src/ClaudeCodeVS/VsixPackage.cs— entry point; starts server, writes lockfile, registers commands.src/ClaudeCodeVS/Protocol/McpWebSocketServer.cs— WebSocket server + auth.src/ClaudeCodeVS/Protocol/JsonRpcDispatcher.cs— MCP handshake + routing.src/ClaudeCodeVS/Protocol/Tools/— 11 MCP tool handlers.src/ClaudeCodeVS/Ide/DiffCoordinator.cs— blockingopen_diffimplementation.src/ClaudeCodeVS/ClaudeCodePackage.vsct— menus + key bindings.
- Protocol reverse-engineering reference: https://github.com/coder/claudecode.nvim
- MCP specification: https://modelcontextprotocol.io/specification/2024-11-05
- Visual Studio SDK: https://learn.microsoft.com/en-us/visualstudio/extensibility/
MIT — see LICENSE.txt.