Mentioned as a testing tool for the MCP server endpoints, allowing HTTP requests to the VSCode command execution service
Used for package management and project dependencies in the VSCode extension development
Primary programming language used to implement the MCP server with TypeScript 5.9+ support
Provides schema validation for MCP tool parameters and API requests to ensure type safety
VSCode Internal Command MCP Server
🚀 一个基于 FastMCP 框架的 VSCode 扩展,将 VSCode 转换为 MCP (Model Context Protocol) 服务器,支持外部客户端通过 HTTP Streaming 和 Server-Sent Events (SSE) 执行 VSCode 内部命令。
✨ 功能特性
- 🌐 HTTP Streaming 支持: 使用
text/event-stream
协议,支持实时通信 - 🔧 VSCode 命令执行: 远程执行任意 VSCode 内部命令
- 📊 工作区信息查询: 获取当前工作区状态和文件信息
- 🛡️ 安全控制: 可配置的命令白名单机制
- 📡 实时状态监控: 状态栏显示服务器运行状态
- 🔗 标准 MCP 协议: 完全兼容 Model Context Protocol 规范
- ⚡ 高性能: 基于 FastMCP 框架,支持并发请求和会话管理
- 🩺 健康检查: 内置健康检查端点
📦 安装
1. 克隆项目
2. 安装依赖
3. 编译项目
4. 在 VSCode 中安装
- 按
F5
启动扩展开发主机 - 或者打包为
.vsix
文件进行安装
⚙️ 配置
在 VSCode 设置中配置服务器参数:
配置说明
配置项 | 类型 | 默认值 | 说明 |
---|---|---|---|
port | number | 8080 | MCP 服务器端口 |
host | string | "localhost" | MCP 服务器主机地址 |
autoStart | boolean | true | 扩展激活时自动启动服务器 |
enableWebSocket | boolean | true | 启用 WebSocket 支持(未来功能) |
allowedCommands | string[] | [] | 允许执行的命令列表(空数组表示允许所有命令) |
🚀 使用方法
启动服务器
- 自动启动: 扩展激活时自动启动(如果
autoStart
为 true) - 手动启动:
- 命令面板:
VSCode MCP Server: Start Server
- 或点击状态栏中的 🚀 FastMCP 按钮
- 命令面板:
服务器地址
- MCP 端点:
http://localhost:8080/mcp
- 健康检查:
http://localhost:8080/health
状态监控
- 状态栏显示: 🚀 FastMCP 🟢 (运行中) / 🚀 FastMCP 🔴 (已停止)
- 命令面板:
VSCode MCP Server: Show Status
查看详细状态
🛠️ 可用工具 (MCP Tools)
1. execute_vscode_command
执行 VSCode 内部命令
参数:
示例:
2. list_vscode_commands
列出所有可用的 VSCode 命令
参数: 无
返回: 命令列表(前20个,如果超过会显示省略提示)
3. get_workspace_info
获取当前工作区信息
参数: 无
返回:
🔌 客户端连接
使用官方 MCP SDK
使用 Cursor
在 Cursor 中配置 MCP 服务器:
使用 curl 测试
🏗️ 技术架构
核心组件
技术栈
- 框架: FastMCP - TypeScript MCP 服务器框架
- 协议: Model Context Protocol (MCP)
- 传输: HTTP Streaming with Server-Sent Events (SSE)
- 验证: Zod Schema 验证
- 平台: VSCode Extension API
网络协议
- 传输类型:
httpStream
- 内容类型:
text/event-stream
- 支持协议: HTTP/1.1, WebSocket (计划中)
- CORS: 默认启用
🔧 开发
项目结构
开发命令
调试
- 在 VSCode 中打开项目
- 按
F5
启动扩展开发主机 - 在新窗口中测试扩展功能
- 查看调试控制台输出
🧪 测试
使用内置测试工具
- 启动服务器后,使用命令:
VSCode MCP Server: Test MCP Tools
- 选择要测试的工具
- 输入必要的参数
- 查看执行结果
使用 FastMCP CLI
🛡️ 安全考虑
命令白名单
为了安全起见,建议配置 allowedCommands
白名单:
网络安全
- 默认只监听
localhost
,避免外部访问 - 支持 CORS,但建议在生产环境中配置适当的源限制
- 所有命令执行都在 VSCode 安全上下文中进行
📝 更新日志
v0.0.1 (当前版本)
- ✅ 基于 FastMCP 框架实现 MCP 服务器
- ✅ 支持 HTTP Streaming 和 SSE
- ✅ 实现三个核心工具:命令执行、命令列表、工作区信息
- ✅ 状态栏集成和实时监控
- ✅ 健康检查端点
- ✅ Zod Schema 参数验证
- ✅ TypeScript 5.9+ 支持
🤝 贡献
欢迎提交 Issue 和 Pull Request!
开发指南
- Fork 项目
- 创建功能分支:
git checkout -b feature/amazing-feature
- 提交更改:
git commit -m 'Add amazing feature'
- 推送分支:
git push origin feature/amazing-feature
- 创建 Pull Request
📄 许可证
MIT License - 详见 LICENSE 文件
🙏 致谢
- FastMCP - 优秀的 TypeScript MCP 框架
- Model Context Protocol - 标准协议规范
- VSCode Extension API - 强大的扩展平台
📞 支持
如果您遇到问题或有疑问:
- 查看 Issues
- 创建新的 Issue
- 查看 FastMCP 文档: https://github.com/punkpeye/fastmcp
🚀 让 VSCode 成为您的 MCP 服务器,释放无限可能!
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Converts VSCode into an MCP server that enables external clients to remotely execute VSCode internal commands, query workspace information, and interact with the editor through HTTP streaming. Built on the FastMCP framework with security controls and real-time monitoring.
Related MCP Servers
- AsecurityAlicenseAqualityTypeScript-based MCP server designed to enhance code editing experiences by providing features such as hover information, code completion, and diagnostics.Last updated -324MIT License
- MIT License
- -securityFlicense-qualityA collection of MCP servers built with FastMCP framework that handle various tasks including customer interviews, E2E testing, and go-live processes, enabling seamless integration with GitHub Copilot through VSCode.Last updated -
- -securityFlicense-qualityA minimal WebSocket-based MCP server implementation that enables modern tool integrations with VSCode, Claude, and other applications.Last updated -1