VS Code MCP Server
A VS Code extension that exposes VS Code's capabilities via the Model Context Protocol (MCP), enabling AI assistants like Claude Code to fully control VS Code.
Features
- 38+ MCP Tools across 7 categories
- HTTP Server on localhost:9002
- Status Bar Toggle for easy control
- Auto-start on VS Code launch
Installation
From Source
# Clone the repository
git clone https://github.com/yourusername/vscode-mcp-server.git
cd vscode-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Install in VS Code (press F5 to test, or package for production)
From VSIX (when published)
code --install-extension vscode-mcp-server-0.1.0.vsix
Usage
Start the Server
- Open VS Code
- The server auto-starts (configurable)
- Look for
MCP :9002 in the status bar
- Click to toggle on/off
Connect from Claude Code
Add to your MCP configuration:
{
"mcpServers": {
"vscode": {
"url": "http://localhost:9002/mcp"
}
}
}
File Operations (6)
| Tool |
Description |
vscode_open_file |
Open file in editor |
vscode_close_file |
Close file/tab |
vscode_save_file |
Save file(s) |
vscode_get_open_files |
List open files |
vscode_read_file |
Read file contents |
vscode_create_file |
Create new file |
Editor Operations (8)
| Tool |
Description |
vscode_goto_line |
Navigate to line/column |
vscode_goto_symbol |
Navigate to symbol |
vscode_get_selection |
Get selected text |
vscode_insert_text |
Insert text at position |
vscode_replace_text |
Replace text in range |
vscode_get_active_editor |
Get editor state |
vscode_get_live_content |
Get live content (including unsaved) |
vscode_watch_changes |
Watch real-time keystrokes/edits |
Code Intelligence (5)
| Tool |
Description |
vscode_get_diagnostics |
Get errors/warnings |
vscode_get_symbols |
Get document symbols |
vscode_find_references |
Find all references |
vscode_get_definition |
Go to definition |
vscode_search_symbols |
Search workspace symbols |
Terminal (6)
| Tool |
Description |
vscode_terminal_create |
Create new terminal |
vscode_terminal_send |
Send command |
vscode_terminal_execute |
Execute command & capture output (with completion detection) |
vscode_terminal_read_output |
Read output file with pagination/grep |
vscode_terminal_list |
List terminals |
vscode_terminal_close |
Close terminal |
Workspace & Tasks (4)
| Tool |
Description |
vscode_run_command |
Execute VS Code command |
vscode_run_task |
Run configured task |
vscode_get_tasks |
List available tasks |
vscode_get_workspace_info |
Get workspace info |
Debug (6)
| Tool |
Description |
vscode_debug_start |
Start debug session |
vscode_debug_stop |
Stop debugging |
vscode_debug_pause |
Pause execution |
vscode_debug_continue |
Continue/step |
vscode_set_breakpoint |
Set breakpoint |
vscode_get_breakpoints |
List breakpoints |
Dashboard (9)
| Tool |
Description |
vscode_dashboard_list_projects |
List all tracked projects with status |
vscode_dashboard_add_project |
Add a project to the dashboard |
vscode_dashboard_remove_project |
Remove a project from tracking |
vscode_dashboard_get_project |
Get detailed project info |
vscode_dashboard_create_terminal |
Create tmux-backed terminal for project |
vscode_dashboard_reorder_projects |
Reorder projects in dashboard |
vscode_dashboard_set_project_color |
Set project accent color |
vscode_dashboard_get_state |
Get full dashboard state with terminal output |
vscode_get_webviews |
List all active webviews |
Info (1)
| Tool |
Description |
vscode_info |
Get VS Code info |
Configuration
| Setting |
Default |
Description |
vscode-mcp-server.port |
9002 |
Server port |
vscode-mcp-server.host |
127.0.0.1 |
Server host |
vscode-mcp-server.autoStart |
true |
Auto-start on launch |
Commands
MCP Server: Start - Start the server
MCP Server: Stop - Stop the server
MCP Server: Toggle - Toggle server on/off
API Endpoints
GET /health - Health check
POST /mcp - MCP protocol endpoint
MCP Automation Runbook (for AI agents)
Use these steps to drive the dashboard and terminals programmatically.
1) Verify server
curl -s http://127.0.0.1:9002/health
2) List dashboard projects
curl -s -X POST http://127.0.0.1:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vscode_dashboard_list_projects","arguments":{"sortBy":"order","includeTerminals":true}}}'
3) Create a project terminal (tmux‑backed)
curl -s -X POST http://127.0.0.1:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"vscode_dashboard_create_terminal","arguments":{"projectPath":"/path/to/project","name":"Claude","show":true}}}'
4) Send a command to a terminal
curl -s -X POST http://127.0.0.1:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"vscode_terminal_send","arguments":{"name":"Claude","text":"pwd","addNewLine":true}}}'
5) Execute a command and capture output
curl -s -X POST http://127.0.0.1:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"vscode_terminal_execute","arguments":{"name":"Claude","command":"git status -sb","tailLines":20}}}'
6) Launch Claude inside a terminal
curl -s -X POST http://127.0.0.1:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"vscode_terminal_send","arguments":{"name":"Claude","text":"claude","addNewLine":true}}}'
Interacting with Dashboard Terminals (tmux)
The dashboard uses tmux-backed embedded terminals. You can interact with them programmatically using tmux commands.
Get Dashboard State
# Get full dashboard state including projects, terminals, and output previews
curl -s -X POST http://127.0.0.1:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vscode_dashboard_get_state","arguments":{"includeTerminalOutput":true,"outputLines":20}}}'
List Active Webviews
curl -s -X POST http://127.0.0.1:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"vscode_get_webviews","arguments":{}}}'
List Embedded Terminal Sessions (tmux)
# List all dashboard terminal sessions
tmux list-sessions
# Example output:
# xvsc_2292df_1769577975165: 1 windows (created Wed Jan 28 14:26:15 2026)
# xvsc_2292df_1769578556182: 1 windows (created Wed Jan 28 14:35:56 2026)
Read Terminal Content
# Read the last 20 lines from a terminal
tmux capture-pane -t SESSION_NAME -p | tail -20
# Read full terminal content
tmux capture-pane -t xvsc_2292df_1769577975165 -p
Send Keystrokes to a Terminal
# Send text and press Enter
tmux send-keys -t SESSION_NAME 'your command here' Enter
# Send special keys
tmux send-keys -t SESSION_NAME Up # Arrow up
tmux send-keys -t SESSION_NAME Down # Arrow down
tmux send-keys -t SESSION_NAME Escape # Escape key
tmux send-keys -t SESSION_NAME Enter # Enter key
tmux send-keys -t SESSION_NAME C-c # Ctrl+C
tmux send-keys -t SESSION_NAME C-a # Ctrl+A
Example: Resume a Claude Code Session
This workflow demonstrates using /resume in a Claude Code terminal:
# 1. Find the Claude Code terminal session
tmux list-sessions | grep xvsc
# 2. Send /resume command
tmux send-keys -t xvsc_2292df_1769577975165 '/resume' Enter
# 3. Wait and read the session list
sleep 2
tmux capture-pane -t xvsc_2292df_1769577975165 -p | tail -20
# 4. Navigate the list (Down arrow)
tmux send-keys -t xvsc_2292df_1769577975165 Down
# 5. Select a session (Enter)
tmux send-keys -t xvsc_2292df_1769577975165 Enter
# 6. Read the resumed conversation
sleep 2
tmux capture-pane -t xvsc_2292df_1769577975165 -p | tail -30
Example: Send a Prompt to Claude Code
# Send a message to Claude Code
tmux send-keys -t xvsc_2292df_1769577975165 'explain how the auth system works' Enter
# Wait for response and read it
sleep 10
tmux capture-pane -t xvsc_2292df_1769577975165 -p | tail -50
Check What's Running in All Terminals
# Loop through all dashboard terminals and show their content
for session in $(tmux list-sessions -F "#{session_name}" | grep xvsc); do
echo "=== $session ==="
tmux capture-pane -t "$session" -p | tail -10
echo ""
done
Clean Up Orphaned Sessions
# Kill all dashboard tmux sessions (use with caution!)
tmux list-sessions -F "#{session_name}" | grep xvsc | while read session; do
tmux kill-session -t "$session"
done
Known Issues
- Terminal sessions may accumulate if windows are not closed properly. Use the cleanup command above to remove orphaned sessions.
Testing
# Run the test script (requires server running)
./test-server.sh
# Or manually test
curl http://localhost:9002/health
curl -X POST http://localhost:9002/mcp \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
AI Integration Guide
See AI_GUIDE.md for a comprehensive guide on what AI assistants can do with this MCP server, including:
- All 40 available tools with descriptions
- Common workflows (code review, debugging, testing)
- Tips for effective AI assistance
Security
- Server binds to localhost only (127.0.0.1)
- No authentication (relies on localhost security)
- Be cautious with terminal commands
Development
# Watch mode
npm run watch
# Debug in VS Code
Press F5
License
MIT
Credits
Inspired by: