SSH网桥MCP
VS Code扩展为Claude Code提供了一个MCP(模型上下文协议)服务器,当通过远程SSH工作时,可以在本地触发通知声音和消息。
特性
- MCP SSE服务器 -使用SSE传输的内置MCP服务器(端口9847)
- 通知声音 -当从远程Claude Code触发时,播放系统会在本地发出声音
- VS代码消息 -在VS代码中显示信息/警告/错误通知
- 远程SSH支持 -通过SSH反向隧道与VS Code Remote SSH无缝协作
建筑
┌─────────────────────────────────────────────────────────────────┐
│ Local Windows/macOS/Linux (VS Code) │
│ ┌────────────────────────────────────────────────────────────┐ │
│ │ ssh-bridge-mcp Extension │ │
│ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ HTTP Server │◄───│ MCP Protocol │ │ Notification │ │ │
│ │ │ :9847 (SSE) │ │ Handler │───▶│ Manager │ │ │
│ │ └──────┬───────┘ └──────────────┘ └──────────────┘ │ │
│ └─────────│──────────────────────────────────────────────────┘ │
│ │ SSH Reverse Tunnel (-R 9847:127.0.0.1:9847) │
└────────────│────────────────────────────────────────────────────┘
│
┌────────────▼────────────────────────────────────────────────────┐
│ Remote Linux Server │
│ ┌──────────────┐ │
│ │ Claude Code │──▶ http://127.0.0.1:9847/sse │
│ │ (MCP Client) │ │
│ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘安装
来自VSIX(推荐)
- 下载或构建
.vsix文件 - 在VS代码中:
Ctrl+Shift+P→Extensions: Install from VSIX... - 选择
ssh-bridge-mcp-x.x.x.vsix文件 - 重新启动VS代码
来源
git clone https://github.com/k-l-lambda/vscode-ssh-bridge-mcp.git
cd vscode-ssh-bridge-mcp
npm install
npm run compile
vsce package远程SSH设置
1.配置SSH反向隧道
添加 RemoteForward 到你当地 ~/.ssh/config:
Host your-remote-server
HostName x.x.x.x
User your-user
RemoteForward 9847 127.0.0.1:98472.重新连接VS Code远程SSH
断开并重新连接到远程服务器,以便隧道生效。
3.验证隧道(在远程服务器上)
curl http://127.0.0.1:9847/health
# Should return: {"status":"ok","port":9847}4.将MCP添加到克劳德代码(在远程服务器上)
claude mcp add ssh-bridge -s user --transport sse http://127.0.0.1:9847/sse5.重新启动克劳德代码
claude
# or restart your existing Claude Code sessionMCP工具
该扩展为Claude Code提供了以下工具:
play_notification
在本地计算机上播放通知声音。
Parameters:
- type: "default" | "success" | "error" | "warning" (optional, default: "default")
- message: string (optional) - Also show a VS Code notificationClaude Code中的示例用法:
“播放通知声音,让我知道构建已完成”
show_message
在VS代码中显示通知消息。
Parameters:
- message: string (required) - The message to display
- type: "info" | "warning" | "error" (optional, default: "info")Claude Code中的示例用法:
“显示一条警告消息,上面写着‘测试失败’”
play_attention
播放引人注目的声音和/或闪烁任务栏按钮。
Parameters:
- sound: boolean (optional, default: true) - Play attention sound
- flash: boolean (optional, default: true) - Flash taskbar button (Windows only)
- flashCount: number (optional, default: 5) - Number of times to flashClaude Code中的示例用法:
“通过声音和任务栏闪烁吸引我的注意力”
browser_navigate
将浏览器导航到URL。
Parameters:
- url: string (required) - URL to navigate tobrowser_screenshot
截取当前页面或特定元素的屏幕截图。
Parameters:
- name: string (required) - Name for the screenshot
- selector: string (optional) - CSS selector for element to screenshot
- width: number (optional, default: 800) - Width in pixels
- height: number (optional, default: 600) - Height in pixels
- remoteHost: string (optional) - SCP destination to transfer screenshot (e.g., "user@host:/path")browser_click
单击页面上的元素。
Parameters:
- selector: string (required) - CSS selector for element to clickbrowser_fill
填写输入字段。
Parameters:
- selector: string (required) - CSS selector for input field
- value: string (required) - Value to fillbrowser_select
从下拉列表中选择一个选项。
Parameters:
- selector: string (required) - CSS selector for select element
- value: string (required) - Value to selectbrowser_hover
将鼠标悬停在页面上的某个元素上。
Parameters:
- selector: string (required) - CSS selector for element to hoverbrowser_evaluate
在浏览器控制台中执行JavaScript。
Parameters:
- script: string (required) - JavaScript code to executebrowser_console
获取浏览器控制台日志。
Parameters:
- filter: "all" | "error" | "warning" | "log" | "info" (optional, default: "all")
- clear: boolean (optional, default: false) - Clear logs after retrievingbrowser_list_pages
列出所有打开的浏览器页面/选项卡。
Parameters: none
Returns:
- pages: Array of {index, url, title, isCurrent}browser_switch_page
按索引切换到特定浏览器页面。
Parameters:
- index: number (required) - Page index (0-based)speak (TTS)
使用Kokoro TTS大声朗读文本(需要单独的TTS服务器)。
Parameters:
- text: string (required) - Text to speak
- voice: "default" | "female" | "male" (optional)
- lang: "en" | "zh" | "auto" (optional, default: "auto")VS代码命令
SSH Bridge: Play Notification Sound-测试通知声音SSH Bridge: Test MCP Connection-显示服务器状态和端口SSH Bridge: Show Setup Instructions-在Web视图中打开安装指南
故障排除
远程MCP连接失败
- 检查扩展是否在本地运行:
# On your local machine
curl http://127.0.0.1:9847/health- 检查SSH隧道:
# On remote server
curl http://127.0.0.1:9847/health如果此操作失败但本地工作,则不配置SSH隧道。
- 重新添加RemoteForward并重新连接:
- 编辑 ~/.ssh/config 在本地计算机上 - 断开VS代码远程SSH连接 - 重新连接以建立隧道
没有声音播放
- 视窗:确保系统声音未静音
- macOS:检查系统首选项→ Sound
- Linux:安装
libcanberra-gtk3-module或确保PulseAudio正在运行
端口9847已在使用中
扩展将自动尝试下一个端口(9848、9849等)。通过以下方式检查实际端口:
- VS代码命令:
SSH Bridge: Test MCP Connection - 或检查输出面板:
SSH Bridge MCP
发展
npm install
npm run watch # Watch mode for development
npm run compile # One-time compile
vsce package # Build VSIX许可证
麻省理工学院
