vscode-helper
Enables AI agents to control VSCode workspaces, including file operations, terminal commands, search, and workspace management.
README
VSCode Helper
A command-line helper tool for controlling VSCode from the terminal and AI agents. This project provides both a standalone CLI interface and an MCP server for AI agent integration, enabling workspace management, file operations, and VSCode control.
Features
- Smart Workspace Detection: Automatically detects active VSCode workspaces using VSCode's own status API
- CLI Interface: Comprehensive command-line tool for VSCode control
- JSON Output Support: Structured output for scripting and automation
- File Operations: Open, create, and manage files in VSCode
- Workspace Management: List, detect, and work with open VSCode workspaces
- Terminal Integration: Execute commands in VSCode terminal
- Search Capabilities: Search files and content across workspace
- MCP Server: Full MCP server implementation for AI agent integration
Installation
From Source
npm install
npm run build
npm install -g .
Global Installation
npm install -g vscode-helper
Usage
CLI Commands
Workspace Management
# Show current active VSCode workspace
vscode-helper workspace
# List all open VSCode workspaces
vscode-helper workspaces
# Get workspace info as JSON
vscode-helper workspace --json
vscode-helper workspaces --json
File Operations
# Open a file in VSCode
vscode-helper open src/server.ts
# Open file at specific line
vscode-helper open src/server.ts --line 42
# Create a new file
vscode-helper create newfile.txt --content "Hello World"
# Select/highlight file in VSCode file explorer
vscode-helper select package.json
# Reveal file in VSCode file explorer
vscode-helper reveal src/server.ts
Workspace Search
# Search for files
vscode-helper search package --type files
# Search file content
vscode-helper search "VSCode" --type content
# Get search results as JSON
vscode-helper search "error" --type content --json
# List workspace files
vscode-helper files
vscode-helper files --json
Terminal & Navigation
# Run a terminal command
vscode-helper run "npm install"
# Focus VSCode file explorer
vscode-helper focus-explorer
MCP Server
# Start MCP server for AI agent integration
vscode-helper server
Key Features
Smart Workspace Detection
The tool intelligently detects your active VSCode workspace by:
- Using VSCode's built-in
code --statusAPI to get currently open workspaces - Prioritizing workspaces that contain your current working directory
- Falling back to workspace indicators (.git, package.json, etc.)
- Using VSCode's recent workspace storage as final fallback
Context-Aware File Operations
When you run vscode-helper select package.json from any terminal location, it will find and select the package.json file in your currently active VSCode workspace, not the terminal's current directory.
JSON Output Support
Most commands support --json flag for structured output:
--jsonflag provides machine-readable output for scripting- Regular output provides human-friendly formatting
- Perfect for integration with other tools and scripts
MCP Server Integration
To integrate with AI agents like Claude Code, add this server to your MCP configuration:
{
"mcpServers": {
"vscode-helper": {
"command": "vscode-helper",
"args": ["server"]
}
}
}
MCP Tools Available:
open_file: Open files in VSCoderun_terminal_command: Execute terminal commandscreate_file: Create new filessearch_workspace: Search files or contentreveal_in_explorer: Reveal files in VSCode file explorerfocus_explorer: Focus the VSCode file explorer viewselect_file_in_explorer: Select/highlight files in VSCode file explorer
MCP Resources Available:
vscode://workspace/files: List workspace filesvscode://editor/content: Current editor content (requires extension)
Architecture
The project consists of:
- VSCode Controller (
src/vscode-controller.ts): Core VSCode integration and workspace detection logic - CLI Interface (
src/cli.ts): Command-line wrapper with argument parsing - MCP Server (
src/server.ts): Handles MCP protocol communication for AI agents
Requirements
- Node.js 18+
- VSCode installed and accessible via
codecommand - Linux/Ubuntu (primary target platform)
- TypeScript for development
Development
# Install dependencies
npm install
# Build
npm run build
# Install locally for testing
npm install -g .
# Run in development
npm run dev
# Test CLI directly
npm run cli -- workspaces
Examples
Working with Multiple VSCode Windows
# List all open VSCode workspaces
$ vscode-helper workspaces
Open VSCode workspaces (3):
project-a - /home/user/projects/project-a
project-b - /home/user/projects/project-b
project-c - /home/user/projects/project-c
# Get the active workspace (based on current context)
$ vscode-helper workspace
Active VSCode workspace: /home/user/projects/project-a
# Select a file in the active workspace from anywhere
$ cd /tmp
$ vscode-helper select src/main.py
Successfully selected src/main.py in VSCode file explorer (workspace: /home/user/projects/project-a)
JSON Integration
# Get workspace data for scripting
$ vscode-helper workspaces --json | jq '.[].name'
"project-a"
"project-b"
"project-c"
# Search and process results
$ vscode-helper search "TODO" --type content --json | jq '.results'
Limitations
- Primarily designed for Linux/Ubuntu environments
- Some features require VSCode to be running
- Terminal integration may vary by desktop environment
- MCP server mode is designed for local usage only
Contributing
This project focuses on local VSCode automation and AI agent integration. Feel free to fork and adapt for your specific needs.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。