⚠️ WARNING: AI-GENERATED CODE AHEAD ⚠️
This entire library was conjured by AI. Every line: TypeScript, bridge daemon, Chrome extension, SSH tunneling, even this README. I just sat there muttering "sure" and "pls no more sudo copy paste"
Safe? I don't know.
Production? Criminal negligence.
Works? Works for me™.
Will it betray you? You're about to give an AI's code sudo access to your machine. If Zalgo comes out of the void whispering your crypto seed phrases, you may just have to give him what he wants, but it's not my fault.
Just close the tab - you were warned. Good luck!
Approve sudo commands from AI assistants (OpenCode/Claude) through a single Chrome extension tab - even over SSH!
Platform: Requires X11, Chrome/Chromium browser, and GUI password dialogs (zenity or kdialog). May work on macOS or WSL2 with proper X server setup, but untested. Windows support unknown.
When your AI assistant needs to run sudo commands, they appear in a Chrome extension for your approval. Works seamlessly across multiple MCP instances and remote SSH servers.
┌──────────────────────────────────────────────────────────────┐
│ OpenCode (local) ──┐ │
│ OpenCode (SSH) ──┼──> Bridge ──> Chrome Extension ──> You │
│ OpenCode (remote)──┘ │
│ │
│ Password Dialog (via X11) appears on your local screen │
└──────────────────────────────────────────────────────────────┘
cd ~/Source/linux/sudo-mcp-custom
npm install
npm run buildnpm run bridgeCopy the token shown (you'll need it next).
- Open Chrome:
chrome://extensions/ - Enable Developer mode (top right)
- Click Load unpacked
- Select:
~/Source/linux/sudo-mcp-custom/extension/ - Paste your token when prompted
Edit ~/.config/opencode/opencode.json:
{
"mcp": {
"sudo-mcp-custom": {
"type": "local",
"enabled": true,
"command": ["node", "/home/YOUR_USERNAME/Source/linux/sudo-mcp-custom/build/index.js"]
}
}
}Replace YOUR_USERNAME with your actual username.
That's it! Now when the AI needs sudo, commands appear in the Chrome extension.
Use sudo commands from OpenCode running on a remote server - approvals appear on your local Chrome!
Host myserver
HostName your-server-ip
User your-username
RemoteForward 9999 localhost:9999
ForwardX11 yes
ForwardX11Trusted yes
Replace myserver, your-server-ip, and your-username with your details.
npm run bridgeKeep this running.
sudo nano /etc/ssh/sshd_configFind and change:
#X11Forwarding no
To:
X11Forwarding yes
Save and restart SSH:
sudo systemctl restart sshdFor Arch Linux:
sudo pacman -S zenityFor Ubuntu/Debian:
sudo apt install zenityFor Fedora/RHEL:
sudo dnf install zenitycd ~/Source/linux/sudo-mcp-custom
npm install
npm run buildSame as step 4 in Quick Start above.
ssh myserverVerify X11 is working:
echo $DISPLAY
# Should show something like: localhost:10.0The approval request will appear in your local Chrome extension!
-
Bridge Daemon (
npm run bridge)- Runs on your local machine
- Routes messages between MCP servers and Chrome extension
- Ports: 9999 (MCP), 9998 (Extension)
-
Chrome Extension
- Single approval tab for all commands
- Desktop notifications with sound
- Flashing badge and title for attention
- Dark mode support
-
MCP Server (runs with OpenCode)
- Detects local vs SSH sessions
- Auto-connects to bridge
- Sends commands for approval
- AI requests sudo command
- MCP sends to bridge (via WebSocket or SSH tunnel)
- Bridge forwards to Chrome extension
- You click Execute in Chrome
- Password dialog appears (local or via X11)
- Command runs, result returns to AI
Remote Server Local Machine
┌──────────────────┐ ┌──────────────────┐
│ MCP Server │ │ Bridge Daemon │
│ ↓ │ │ ↓ │
│ localhost:9999 ──┼─[SSH tunnel]→ localhost:9999 │
└──────────────────┘ │ ↓ │
│ localhost:9998 │
│ ↓ │
│ Chrome Extension │
└──────────────────┘
The RemoteForward in SSH config creates a tunnel so remote MCP can connect to your local bridge.
When a new command arrives, the extension:
✅ Shows desktop notification (with sound)
✅ Flashes badge (red/orange)
✅ Flashes tab title ("🔔 NEW SUDO COMMAND!")
✅ Plays beep sound
✅ Auto-focuses window/tab
✅ Animates new command card
You won't miss a command!
# Start bridge (one terminal, keep running)
npm run bridge
# Start OpenCode (asks for sudo commands as needed)# On local machine: Start bridge
npm run bridge
# SSH to remote
ssh myserver
# On remote: Use OpenCode as normal
# Commands appear in your local Chrome!Check X11 forwarding:
# After SSH, run:
echo $DISPLAY
# Should show localhost:10.0 or similar, NOT emptyIf empty:
- Check remote
/etc/ssh/sshd_confighasX11Forwarding yes - Restart sshd:
sudo systemctl restart sshd - Reconnect SSH
Check bridge is running:
ps aux | grep 'node.*bridge'If not running:
npm run bridge-
Check token matches:
cat ~/.config/sudo-mcp/bridge-token -
In Chrome extension popup, verify token
-
Reload extension:
chrome://extensions/- Click reload button
Kill stale SSH tunnel:
ssh myserver "pkill -f 'sshd.*notty'"
# Reconnect
ssh myserverAdd each server to ~/.ssh/config:
Host server1
HostName 192.168.1.10
RemoteForward 9999 localhost:9999
ForwardX11 yes
Host server2
HostName 192.168.1.20
RemoteForward 9999 localhost:9999
ForwardX11 yes
All servers connect to the same bridge. All commands appear in one Chrome tab!
# Start detached
nohup npm run bridge > /tmp/sudo-mcp-bridge.log 2>&1 &
# Stop it later
pkill -f 'node.*bridge'SUDO_MCP_USE_HTTP=true npm startEach MCP instance opens its own browser window at http://localhost:3000+
- Commands are blocked: Only catastrophic commands (e.g.,
rm -rf /) - Password required: You must enter your sudo password each time (or every ~15 min if cached)
- Local bridge: Token is stored at
~/.config/sudo-mcp/bridge-token - Review everything: Always check commands before clicking Execute!
sudo-mcp-custom/
├── src/ # TypeScript source
├── build/ # Compiled JavaScript
├── extension/ # Chrome extension
│ ├── background/ # Service worker
│ ├── ui/ # Approval interface
│ └── manifest.json
├── config/
│ └── blocklist.json # Blocked commands
└── package.json
Token location: ~/.config/sudo-mcp/bridge-token
# Build
npm run build
# Start bridge (local machine only)
npm run bridge
# Test MCP server directly
npm start
# Development (watch mode)
npm run devBuilt for OpenCode using the Model Context Protocol (MCP).
Requirements:
- Node.js 18+
- Linux with X11
- Chrome/Chromium browser
zenityorkdialog(for password dialogs over SSH)
ISC