Skip to content

About

Auto-accept Run/Accept/Keep buttons in Cursor agent mode via Chrome DevTools Protocol

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

cursor-auto-accept

Auto-approve Run / Accept / Allow buttons in Cursor agent mode — no more clicking through every confirmation dialog.

Uses the Chrome DevTools Protocol (CDP) to connect to Cursor's Electron UI and automatically click approval buttons as they appear.

How It Works

Cursor (Electron)          This Script
┌──────────────────┐       ┌──────────────────┐
│  Agent pops up   │  CDP  │  Detects button   │
│  [Run] [Accept]  │◄─────►│  Clicks it        │
│  Button vanishes │  9222 │  Logs the action   │
└──────────────────┘       └──────────────────┘

The script polls Cursor's DOM every 500ms (configurable), finds buttons matching a whitelist, and triggers a click. Works with both local and remote (SSH) development — the script only talks to the local Cursor UI.

Prerequisites

  • macOS or Windows (Linux should also work)
  • Node.js >= 18
  • Cursor installed at the default path

Quick Start

1. Launch Cursor with the debug port

Quit Cursor completely first (Cmd+Q on Mac, make sure no background processes remain), then:

macOS:

./start-cursor-debug.sh

Or manually:

/Applications/Cursor.app/Contents/MacOS/Cursor --remote-debugging-port=9222

Windows:

Add --remote-debugging-port=9222 to your Cursor shortcut's target field, or run:

& "$env:LOCALAPPDATA\Programs\cursor\Cursor.exe" --remote-debugging-port=9222

2. Install dependencies and run

In a separate terminal window:

npm install
npm start

You should see:

[xx:xx:xx] 🔗  Connected to Cursor via CDP
[xx:xx:xx] Monitoring for Accept / Run buttons...

Done. Every approval popup will now be auto-clicked.

3. Stop

Press Ctrl+C in the script's terminal. Cursor returns to normal manual-approval mode instantly.

Configuration

Environment Variable Default Description
CDP_PORT 9222 Chrome DevTools Protocol port
POLL_MS 300 Polling interval in milliseconds
TELEGRAM_BOT_TOKEN — Telegram Bot API token (from @BotFather)
TELEGRAM_CHAT_ID — Telegram chat/user ID to send messages to
WECOM_WEBHOOK_URL — WeCom (企业微信) bot webhook URL
PUSHPLUS_TOKEN — PushPlus token for WeChat push
NOTIFY_COOLDOWN_MS 30000 Min interval between notifications (ms)

Example with custom settings:

CDP_PORT=9333 POLL_MS=200 npm start

Fallback Notifications (Telegram / WeChat)

When the script encounters an approval button it doesn't recognize (not in whitelist or blacklist), it sends a push notification so you can manually intervene. This is a safety net for unexpected dialogs.

Telegram (Two-Way Remote Control)

When configured, Telegram becomes a full remote control for Cursor — not just one-way notifications.

What it does:

  • Blocked by unknown button → sends screenshot + inline buttons to TG
  • You reply with text → typed into Cursor chat + Enter
  • You tap an inline button → clicks that button in Cursor
  • You can send commands anytime (even when not blocked)

TG Bot commands:

Command Action
/ss Take and send a screenshot
/status Check if script is running
/click <text> Click a button matching the text
/key <combo> Send key combo (e.g. cmd+shift+p, enter, esc)
/type <text> Type text without pressing Enter
/help Show all commands
Any other text Type into Cursor chat + press Enter

Setup:

  1. Create a bot via @BotFather, copy the token
  2. Get your chat ID via @userinfobot
  3. Send any message to your bot first (so it can reply to you)
  4. Run:
TELEGRAM_BOT_TOKEN=123456:ABC-DEF TELEGRAM_CHAT_ID=your_id npm start

WeChat via WeCom (企业微信) Webhook

  1. In your WeCom group, add a bot and copy the webhook URL
  2. Run:
WECOM_WEBHOOK_URL="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx" npm start

WeChat via PushPlus (微信推送)

  1. Sign up at pushplus.plus, copy your token
  2. Run:
PUSHPLUS_TOKEN=your_token npm start

You can enable multiple channels simultaneously. Notifications are rate-limited (default: once per 30 seconds) to avoid spam.

What Gets Auto-Clicked

The script uses seven strategies to catch all approval types in Cursor:

Approval Type What's Clicked How It's Detected
Terminal commands "Run" button button.ui-button inside .ui-shell-tool-call__approval-row
Inline code edits Accept button (⌘Y) button.partialHoverButton (non-secondary)
File changes "Keep File" / "Keep All" <span class="truncate"> text match
Dialogs "OK" / "Accept" / "Allow" .monaco-button text match
Unknown buttons Not clicked — sends notification Buttons in approval containers not in whitelist

Full text whitelist (case-insensitive): Run, Keep File, Keep All, Accept, Allow, Approve, Run Command, Save All & Run, Accept All, Continue, Proceed, Yes, Confirm, OK.

To modify, edit the WL set in auto-accept.js.

Troubleshooting

Problem Fix
"Cannot reach Cursor on port 9222" Make sure you fully quit Cursor before relaunching with the debug flag. Use pkill -f Cursor to kill lingering processes.
Script connects but nothing gets auto-clicked Cursor may have updated its button labels/DOM. Open http://localhost:9222 in a browser to inspect the UI and update BUTTON_WHITELIST.
"remote-debugging-port is not in the list of known options" This warning is harmless. The flag is passed through to Chromium and still works.

Security Notice

  • Port 9222 grants full access to Cursor's UI from any local process. Only use this on machines you trust.
  • The script does not inspect command content — it will approve rm -rf / just as happily as echo hello. Use at your own risk.
  • This is an unofficial hack, not a Cursor feature. It may break after updates.

License

MIT

About

Auto-accept Run/Accept/Keep buttons in Cursor agent mode via Chrome DevTools Protocol

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages