|
| 1 | +# ViperIDE MCP Server |
| 2 | + |
| 3 | +An MCP (Model Context Protocol) server that gives Claude full remote control of [ViperIDE](https://viper-ide.org), a MicroPython/CircuitPython IDE. The IDE opens in your browser for direct interaction while Claude simultaneously controls it via MCP tools. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +The MCP server acts as a bridge between Claude and ViperIDE running in your browser. It also provides a serial-to-WebSocket bridge so USB devices can be connected without browser permission dialogs. |
| 8 | + |
| 9 | +| Component | Role | Connection | |
| 10 | +|---|---|---| |
| 11 | +| **Claude** (Code/Desktop) | Sends MCP tool calls | stdio JSON-RPC to MCP server | |
| 12 | +| **MCP Server** (Node.js) | Routes commands, serves IDE, bridges serial | localhost HTTP + WebSocket | |
| 13 | +| **Browser** (ViperIDE) | IDE UI, executes commands on device | WS control channel (`/ws`) | |
| 14 | +| **USB Device** (MicroPython) | Target hardware | Serial port via WS bridge (`/serial/...`) | |
| 15 | + |
| 16 | +The MCP server: |
| 17 | +1. Serves the built ViperIDE on a random localhost port |
| 18 | +2. Opens your default browser to the IDE |
| 19 | +3. Maintains a WebSocket control channel for sending commands |
| 20 | +4. Exposes IDE operations as MCP tools that Claude can call |
| 21 | + |
| 22 | +Both you and Claude can interact with the IDE simultaneously. |
| 23 | + |
| 24 | +## Install |
| 25 | + |
| 26 | +### Claude Desktop |
| 27 | + |
| 28 | +Download the `.mcpb` bundle for your platform from [Releases](https://github.com/andrewleech/ViperIDE/releases). In Claude Desktop, go to Settings > Extensions > Advanced Settings > Install Extension, then select the `.mcpb` file. |
| 29 | + |
| 30 | +### Claude Code |
| 31 | + |
| 32 | +```bash |
| 33 | +claude mcp add viperIDE -- npx -y @andrewleech/viperide-mcp |
| 34 | +``` |
| 35 | + |
| 36 | +### From source |
| 37 | + |
| 38 | +```bash |
| 39 | +git clone https://github.com/andrewleech/ViperIDE.git |
| 40 | +cd ViperIDE && npm install && python3 build.py |
| 41 | +cd mcp && npm install |
| 42 | +claude mcp add viperIDE -- node $(pwd)/src/index.js |
| 43 | +``` |
| 44 | + |
| 45 | +## Available Tools |
| 46 | + |
| 47 | +### Connection |
| 48 | +| Tool | Description | |
| 49 | +|---|---| |
| 50 | +| `viperIDE_get_status` | Connection status, device info, open file, editor state | |
| 51 | +| `viperIDE_connect_device` | Connect via WebSocket (`ws`), virtual device (`vm`), or prompt user for USB/BLE | |
| 52 | +| `viperIDE_connect_serial` | Connect to a USB serial MicroPython device via the local WebSocket bridge | |
| 53 | +| `viperIDE_list_serial_ports` | List available USB serial ports with device details | |
| 54 | +| `viperIDE_disconnect_device` | Disconnect current device | |
| 55 | + |
| 56 | +### File Operations (on device) |
| 57 | +| Tool | Description | |
| 58 | +|---|---| |
| 59 | +| `viperIDE_list_files` | List all files and directories with sizes | |
| 60 | +| `viperIDE_read_file` | Read file content | |
| 61 | +| `viperIDE_write_file` | Write content to file (creates parent dirs) | |
| 62 | +| `viperIDE_delete_file` | Delete a file | |
| 63 | +| `viperIDE_delete_dir` | Delete a directory | |
| 64 | +| `viperIDE_mkdir` | Create a directory | |
| 65 | +| `viperIDE_create_file` | Create a new file and open it in the editor | |
| 66 | + |
| 67 | +### Editor |
| 68 | +| Tool | Description | |
| 69 | +|---|---| |
| 70 | +| `viperIDE_open_file` | Open a device file in the editor | |
| 71 | +| `viperIDE_get_editor` | Get current editor content and filename | |
| 72 | +| `viperIDE_set_editor` | Replace editor content | |
| 73 | +| `viperIDE_save_file` | Save editor content to device | |
| 74 | + |
| 75 | +### Execution |
| 76 | +| Tool | Description | |
| 77 | +|---|---| |
| 78 | +| `viperIDE_run_file` | Run current file on device (non-blocking) | |
| 79 | +| `viperIDE_stop` | Interrupt running script (Ctrl-C) | |
| 80 | +| `viperIDE_reboot` | Reboot device (soft/hard/bootloader) | |
| 81 | + |
| 82 | +### Terminal |
| 83 | +| Tool | Description | |
| 84 | +|---|---| |
| 85 | +| `viperIDE_read_terminal` | Read REPL output | |
| 86 | +| `viperIDE_write_terminal` | Send input to REPL | |
| 87 | +| `viperIDE_clear_terminal` | Clear terminal | |
| 88 | + |
| 89 | +### Packages |
| 90 | +| Tool | Description | |
| 91 | +|---|---| |
| 92 | +| `viperIDE_install_package` | Install a MicroPython package by name or URL | |
| 93 | + |
| 94 | +## USB Serial Bridge |
| 95 | + |
| 96 | +The MCP server includes a serial-to-WebSocket bridge that lets Claude connect directly to USB serial MicroPython devices without requiring the browser's WebSerial permission picker. |
| 97 | + |
| 98 | +1. Use `viperIDE_list_serial_ports` to discover connected devices |
| 99 | +2. Use `viperIDE_connect_serial` with the device path to connect |
| 100 | + |
| 101 | +The bridge opens the serial port at 115200 baud and fakes a WebREPL handshake so ViperIDE's existing WebSocket transport works unchanged. Multiple devices can be bridged simultaneously. |
| 102 | + |
| 103 | +Requires the `serialport` npm package (installed automatically with `npm install`). |
| 104 | + |
| 105 | +## Limitations |
| 106 | + |
| 107 | +- **Bluetooth connections** require the user to click the connect button in the browser (browser security policy requires a user gesture for device picker dialogs). |
| 108 | +- **USB connections** can be made via the serial bridge (`viperIDE_connect_serial`) without user interaction, or via the browser's WebSerial API which requires a user gesture. |
| 109 | +- **WebSocket and VM connections** can be initiated fully by Claude. |
| 110 | +- Running scripts is fire-and-forget. Use `read_terminal` to monitor output and `stop` to interrupt. |
| 111 | +- Only one browser tab should be connected to the MCP server at a time. |
| 112 | + |
| 113 | +## Development |
| 114 | + |
| 115 | +During development, you can run the MCP server directly: |
| 116 | + |
| 117 | +```bash |
| 118 | +# Build ViperIDE first |
| 119 | +npm install && python3 build.py |
| 120 | + |
| 121 | +# Install MCP deps |
| 122 | +cd mcp && npm install |
| 123 | + |
| 124 | +# Run the server (logs to stderr, MCP protocol on stdio) |
| 125 | +node mcp/src/index.js |
| 126 | +``` |
| 127 | + |
| 128 | +The server picks a random port and opens the browser automatically. |
0 commit comments