Skip to main content
AI Intervention Agent

AI Intervention Agent

Real-time user intervention for MCP agents — pause, course-correct, resume.

PyPI MCP Compatible License: MIT

English | 简体中文


Ever had your AI agent confidently walk off in the wrong direction mid-task? AI Intervention Agent gives you a Web UI to pause the agent at key moments, review what it's about to do, type a course-correction, attach screenshots, and resume — all through the MCP interactive_feedback tool, without ending the conversation.

Works with Cursor, VS Code, Claude Code, Augment, Windsurf, Trae, and more.

Quick start

Quickest: ask your AI to install it for you

If your IDE/CLI has an AI agent (Cursor, Claude Code, VS Code, Windsurf, Trae, Augment, ...), paste the prompt below in chat and let it write the config for you.

Click to copy the install prompt
Please configure my IDE / AI tool to use the `ai-intervention-agent` MCP server:

1. Locate the correct MCP config file for my current IDE
   (e.g. `.cursor/mcp.json` or `~/.cursor/mcp.json` for Cursor,
    `~/.claude.json` for Claude Code,
    `.vscode/mcp.json` for VS Code).
2. Add this entry under `mcpServers`:
   - command: `uvx`
   - args: `["ai-intervention-agent"]`
   - timeout: 600
   - autoApprove: `["interactive_feedback"]`
3. Append the project's recommended prompt rules
   (the "Prompt snippet (copy/paste)" block in this README)
   to my agent rules / system prompt, so the agent always asks me
   through `interactive_feedback` instead of ending tasks silently.
4. Verify by listing MCP servers and confirming `ai-intervention-agent` is loaded.

Option 1: Using uvx (Recommended)

Install in Cursor Install in VS Code

Configure your AI tool to launch the MCP server directly via uvx (this automatically installs and runs the latest version):

{
  "mcpServers": {
    "ai-intervention-agent": {
      "command": "uvx",
      "args": ["ai-intervention-agent"],
      "timeout": 600,
      "autoApprove": ["interactive_feedback"]
    }
  }
}

Option 2: Using pip

  1. First, install the package manually (please remember to manually pip install --upgrade ai-intervention-agent periodically to get updates):
pip install ai-intervention-agent
  1. Configure your AI tool to launch the installed MCP server:
{
  "mcpServers": {
    "ai-intervention-agent": {
      "command": "ai-intervention-agent",
      "args": [],
      "timeout": 600,
      "autoApprove": ["interactive_feedback"]
    }
  }
}

[!NOTE] interactive_feedback is a long-running tool. Some clients have a hard request timeout, so the Web UI provides a countdown + auto re-submit option to keep sessions alive.

  • Default: feedback.frontend_countdown=240 seconds
  • Range: 0 (disabled) or [10, 3600] seconds. The default 240 stays under the common 300s session hard timeout; raise it intentionally when your client allows longer turns.
  1. (Optional) Customize your config:
  • On first run, config.toml will be created under your OS user config directory (see docs/configuration.md).
  • Example:
[web_ui]
port = 8080

[feedback]
frontend_countdown = 240
backend_max_wait = 600
Prompt snippet (copy/paste)
- Only ask me through the MCP `ai-intervention-agent` tool; do not ask directly in chat or ask for end-of-task confirmation in chat.
- If a tool call fails, keep asking again through `ai-intervention-agent` instead of making assumptions, until the tool call succeeds.

ai-intervention-agent usage details:

- If requirements are unclear, use `ai-intervention-agent` to ask for clarification with predefined options.
- If there are multiple approaches, use `ai-intervention-agent` to ask instead of deciding unilaterally.
- If a plan/strategy needs to change, use `ai-intervention-agent` to ask instead of deciding unilaterally.
- Before finishing a request, always ask for feedback via `ai-intervention-agent`.
- Do not end the conversation/request unless the user explicitly allows it via `ai-intervention-agent`.

Screenshots

Desktop - feedback page (multi-task tabs, code highlighting, predefined options) Mobile - feedback page

Feedback page · auto switches between dark/light · multi-task tabs with independent countdowns

More screenshots (empty state + settings)

Desktop - empty state Mobile - empty state

Empty state · waiting for the next interactive request

Desktop - settings (notifications, Bark, feedback) Mobile - settings

Settings · notifications · Bark · sound · feedback countdown · auto switches between dark/light

Key features

  • Real-time intervention — the agent pauses and waits for your input via interactive_feedback
  • 🖥️ Web UI — Markdown, code highlighting, and math rendering out of the box
  • 🗂️ Multi-task tabs — switch between concurrent requests, each with its own countdown
  • 🔁 Auto re-submit — keep long sessions alive past client hard timeouts; at zero your typed text and checked options are submitted, never an empty prompt
  • ⏱️ Typing-hold — the countdown auto-extends while you type and never fires mid-input (web page and VS Code extension alike)
  • 🔔 Notifications — web / sound / system / Bark, plus custom notification sound upload
  • 🌐 SSH / LAN friendly — works behind port forwarding; mDNS publishes a <host>.local URL when supported
  • 🏷️ Header chips & Yes/No buttons — per-task header_label context chip, or question_type='yesno' for one-click binary decisions
  • 🎨 Custom placeholder hints — per-task feedback_placeholder overrides the textarea hint
  • 🌏 i18n — Web UI + VS Code extension shipped in en / zh-CN / zh-TW
  • Productivity shortcuts — keyboard cheatsheet (press ?), per-task draft autosave, configurable submit mode, live character counter
  • 🟢 SSE liveness indicator — 3-state corner badge shows whether the page is in sync with the backend
  • 📱 PWA + offline-aware — installable from the browser's native menu; a branded offline page with auto-recovery replaces the default error screen
  • WCAG 2.1 AA accessible — contrast, Name/Role/Value, focus management, prefers-reduced-motion / prefers-contrast: more all audited and locked by invariant tests
  • 🛡️ Stable install — built on Flask 3.x with conservative dependency pins; immune to the Starlette 1.0 breaking change that broke several MCP feedback servers in early 2026

Architecture diagram, "how it works" flow, production middleware chain, server self-info resource, and MCP-spec compliance details live under docs/api/index.md and docs/mcp_tools.md.

Architecture overview

A bird's-eye view of how AIIA's components fit together — useful when you're integrating a new client (custom MCP host, alternate IDE plugin) or debugging a cross-component issue.

graph LR
    subgraph Clients["Clients (any MCP host)"]
        A1[LLM Agent<br/>Cursor / Cline / Augment]
        A2[Web browser<br/>multi-task dashboard]
        A3[VS Code extension<br/>sidebar webview]
        A4[CLI<br/>--print-config / --version]
    end

    subgraph Backend["AIIA backend (single Python process)"]
        B1[MCP server<br/>stdio + interactive_feedback]
        B2[Flask web server<br/>/api/* + SSE bus]
        B3[Task queue<br/>RW-lock + persist]
        B4[Notification manager<br/>browser / system / Bark]
        B5[Config manager<br/>TOML + env override]
    end

    subgraph External["External"]
        E1[File system<br/>config.toml + tasks.json]
        E2[Browser / OS<br/>system notifications]
        E3[Bark API<br/>iOS push]
    end

    A1 -- MCP stdio --> B1
    A2 -- HTTP + SSE --> B2
    A3 -- HTTP + SSE --> B2
    A4 -- module import --> B5

    B1 -- enqueue task --> B3
    B2 -- read / mutate --> B3
    B3 -- task_changed event --> B2
    B2 -- "broadcast SSE<br/>(R51-B heartbeat 25s)" --> A2
    B2 -- broadcast SSE --> A3
    B3 -- on add_task --> B4
    B4 -- "Web Notification API" --> E2
    B4 -- POST --> E3
    B5 -- read / watch mtime --> E1
    B3 -- persist on mutate --> E1

Key invariants (locked by tests in tests/):

  • task_changed SSE payload schema enforced cross-language (Python ↔ JS, test_feat_sse_cross_language_schema_r297.py).
  • SSE heartbeat = 25s, cleanup interval = 5s, hot-path throttle = 30s, JS health check = 30s — locked across all source files (test_feat_perf_baseline_const_r296.py).
  • Plus a static single-tool MCP surface, AST-based lock-acquisition-order contracts (deadlock-freedom proven statically), and a lazy-init audit — see docs/contributor-guide-invariant-tests.md for the full catalogue.

For deeper subsystem detail (config schema, MCP tool reference, i18n strategy, troubleshooting), follow the links in Documentation below.

Agent / Glass mode workflow

AIIA is designed for long-running autonomous agent loops (Cursor Composer, Cursor Glass mode, Cline, Augment, Trae) where the LLM calls interactive_feedback many times during a single run. The combined agent-side parameters + user-side UX features below let a human reviewer decide in < 5 seconds per task, so the agent never blocks the flow longer than necessary.

How a single interaction flows

sequenceDiagram
    participant Agent as LLM Agent<br/>(Cursor / Cline)
    participant MCP as MCP transport
    participant AIIA as AIIA backend<br/>(Flask + SSE)
    participant UI as Web UI / VS Code
    participant Human as Human reviewer

    Agent->>MCP: interactive_feedback(message,<br/>header_label, question_type, ...)
    MCP->>AIIA: POST /api/tasks
    AIIA->>UI: SSE task.created
    UI->>Human: Browser/system notification<br/>+ countdown timer
    Note over Human: Reads chip + prompt,<br/>clicks Yes/No or types reply
    Human->>UI: Submit
    UI->>AIIA: POST /api/tasks/{id}/complete
    AIIA->>MCP: SSE task.completed (+ ctx.info)
    MCP->>Agent: Returns text + images + selected options
    Note over Agent: Resumes execution<br/>with human input

Failure & recovery flows

Beyond the happy path above, three boundary cases keep long-running Agent / Glass-mode sessions resilient: auto-resubmit (human steps away), SSE reconnect (network drop), and typing-hold (human is typing — never interrupt).

sequenceDiagram
    autonumber
    participant Agent as LLM Agent
    participant AIIA as AIIA backend
    participant UI as Web UI
    participant Human as Human reviewer

    Note over Agent,Human: ① Auto-resubmit (human stepped away)
    Agent->>AIIA: interactive_feedback<br/>(auto_resubmit_timeout=120)
    AIIA->>UI: SSE task.created (countdown=120s)
    Note over UI: countdown hits 0<br/>(human not typing)
    UI->>AIIA: POST /api/tasks/{id}/auto-resubmit
    AIIA->>Agent: SSE task.completed<br/>(with "auto-resubmit" marker)

    Note over UI,AIIA: ② SSE drop → degraded poll → reconnect
    UI--xAIIA: SSE disconnect (sleep/network jitter)
    UI->>AIIA: GET /api/tasks (fallback poll, every 5s)
    UI->>AIIA: SSE reconnect (exponential backoff)
    AIIA-->>UI: SSE resumed

    Note over Agent,Human: ③ Typing-hold (human typing — never interrupt)
    Agent->>AIIA: interactive_feedback<br/>(auto_resubmit_timeout=60)
    UI->>Human: countdown shows 60s
    Human->>UI: starts typing feedback
    Note over UI: countdown auto-extends while typing<br/>never fires mid-input (typing-hold)
    Human->>UI: stops typing + submits
    UI->>AIIA: POST /api/tasks/{id}/complete
    AIIA->>Agent: SSE task.completed (full reply)

Agent-side parameters (LLM passes these via MCP)

Parameter Purpose Max Source
header_label One-word context chip in task pane (Auth, DB, i18n) 16 chars gemini-cli ask_user.header
question_type='yesno' Hide textarea + render 2-button binary decision gemini-cli ask_user
feedback_placeholder Per-task textarea hint (overrides global i18n) 200 chars gemini-cli ask_user
auto_resubmit_timeout Per-task countdown override (0 = disable) [0, 3600] sec AIIA native
predefined_options Multi-select chips with optional default: true recommendation 10000 chars/each AIIA + upstream parity
loop_id + 4 loop fields Group multi-round feedback into one loop: objective, phase, success criteria, iteration label 32–500 chars AIIA loop engineering

Full parameter reference + a complete Agent-mode call example lives in docs/mcp_tools.md#agent-mode-parameters-cursor--composer--cline--augment--trae.

Loop engineering (long autonomous runs): rounds sharing a loop_id render a loop-context strip above the prompt and a collapsible "Rounds" timeline of every completed round's verdict, backed by GET /api/loops. See docs/mcp_tools.md#loop-engineering-parameters-long-autonomous-runs.

User-side workflow features (built into the Web UI)

  • Multi-task tabs — parallel requests each get their own tab + independent countdown ring
  • Per-task draft autosave — switching tabs never loses an in-progress reply
  • Typing-hold auto-extension — the countdown extends itself while you type and never fires mid-input
  • Custom notification sound — upload a short audio file for a distinct Agent-mode chime
  • Per-task images — paste screenshots inline, returned to the agent as MCP ImageContent blocks
  • SSE liveness badge — green/orange/red corner indicator shows whether the page is in sync

Recommended LLM system prompt

To force the agent to actually use this tool instead of "auto-finishing" the task, append the snippet under Prompt snippet (copy/paste) to your IDE's system prompt / .cursorrules.

VS Code extension (optional)

Open VSX version Open VSX downloads Open VSX rating

Item Value
Purpose Embed the interaction panel into VS Code’s sidebar to avoid switching to a browser.
Install (Open VSX) Open VSX
Download VSIX (GitHub Release) GitHub Releases
Setting ai-intervention-agent.serverUrl (should match your Web UI URL, e.g. http://localhost:8080; you can change web_ui.port in config.toml.default)
Other settings ai-intervention-agent.logLevel (Output → AI Intervention Agent). macOS native notifications are enabled by default and can be toggled in the sidebar's Notification Settings panel. See packages/vscode/README.md for the full settings list and the AppleScript executor security model.

Configuration

Item Value
Docs (English) docs/configuration.md
Docs (简体中文) docs/configuration.zh-CN.md
Default template config.toml.default (on first run it will be copied to config.toml)
OS User config directory
Linux ~/.config/ai-intervention-agent/
macOS ~/Library/Application Support/ai-intervention-agent/
Windows %APPDATA%/ai-intervention-agent/

Quick overrides (no file edits required)

For uvx, Docker, systemd, or SSH-remote runtimes where editing config.toml is awkward, the most-used web_ui settings can be overridden by env var at process startup:

export AI_INTERVENTION_AGENT_WEB_UI_HOST=0.0.0.0      # default 127.0.0.1
export AI_INTERVENTION_AGENT_WEB_UI_PORT=8181         # default 8080, range [1, 65535]
export AI_INTERVENTION_AGENT_WEB_UI_LANGUAGE=en       # auto / en / zh-CN / zh-TW
uvx ai-intervention-agent

Invalid values log a WARNING and fall back to config.toml/defaults so a typo never blocks server startup. See docs/configuration.md#environment-variable-overrides for the full surface (timeouts, log level, etc.).

CLI inspection

ai-intervention-agent --version       # or -V — print version and exit
ai-intervention-agent --help          # or -h — show usage + config hints
ai-intervention-agent --print-config  # dump effective merged config + env overrides

--print-config answers "is my port 8181 because of env, or config.toml?" in one shell pipeline — output is JSON (jq friendly) with the loaded config path, resolved sections (secret-like fields auto-redacted), and active env overrides. network_security is filtered out at the ConfigManager.get_all() boundary (same trust level as /api/system/health).

📱 Recommended iPhone setup: Shortcuts + Bark

The smoothest way to open the Web UI on an iPhone is to wrap it in a Shortcuts automation, then point Bark notification taps straight at it — no address bar, no install, an app-like experience:

  1. Open the built-in Shortcuts app on your iPhone.
  2. Tap + to create a new shortcut and name it ai intervention agent.
  3. Add the first action: search for URL and enter your Web UI address (e.g. http://ai.local:8081).
  4. Add the second action: search for Show Web Page (older iOS versions call it "Show Web View"); it automatically consumes the URL from step 3.

Then enable Bark in the [notification] section of config.toml and point the tap action at that shortcut:

[notification]
bark_enabled = true
bark_url = "https://api.day.app/push"   # or your self-hosted Bark server
bark_device_key = "your-device-key"
bark_action = "url"
# Tap the Bark notification → launch the shortcut → "Show Web Page" opens the Web UI
bark_url_template = "shortcuts://run-shortcut?name=ai%20intervention%20agent"

bark_url_template accepts any scheme:// deep link (not just http/https); URL-encode spaces in the shortcut name (space → %20). To open the task page directly in the browser instead, keep the default {base_url}/?task_id={task_id}.

Documentation

Related projects

Project Stars (approx.) Focus
mcp-feedback-enhanced (Minidoracat) ~3.8k Largest sibling; Web UI + Tauri desktop app, auto-command execution, SSH Remote / WSL detection.
cunzhi (imhuso) ~1.4k Chinese-language project focused on preventing premature task completion.
Relay (andeya) new Multi-IDE relay, multi-tab session merging, native desktop window, Cursor usage monitoring.
interactive-feedback-mcp (Node.js) new Node.js port with WebSocket UI and Speech-to-Text via OpenAI Whisper.
interactive-feedback-mcp (junanchn) ~50 Win32-native always-on-top window, auto-reply rules.
interactive-feedback-mcp (poliva) ~310 Direct ancestor fork (see Acknowledgements); minimal Python MCP, single feedback dialog.
interactive-feedback-mcp (Pursue-LLL) ~30 Independent smaller-scale fork emphasising minimal dependencies.

Where AIIA sits on the spectrum: AIIA targets the operationally deep end — Web UI + VS Code extension sharing one backend, production-grade observability (/metrics Prometheus endpoint + a reference Grafana dashboard), bilingual i18n + docs, strict invariant test discipline (8,200+ tests + 1,050+ subtests across 40 audit cycles), and a 5-job release pipeline. Want the smallest drop-in? poliva's fork. A desktop app? mcp-feedback-enhanced. Voice / multi-tab UI? Relay or the Node.js fork. Full-stack operational integration? AIIA.

Feature gap callouts (contributions welcome): Speech-to-Text input, always-on-top native window, Cursor usage monitoring, multi-tab session merging UI.

Star counts are approximate snapshots (last reviewed 2026-06); check each upstream for current numbers. Submit a PR if you'd like another related project listed.

Acknowledgements

This project's heritage traces back to Fábio Ferreira (2024) and Pau Oliva (2025), whose original noopstudios/interactive-feedback-mcp and poliva/interactive-feedback-mcp seeded the MCP interactive_feedback tool surface. Their copyright notices are preserved in LICENSE per the MIT license terms. The v1.5.x line is a substantial rewrite — Web UI, VS Code extension, i18n, notification stack, CI/CD pipeline — owned and maintained by @xiadengma (PyPI / Open VSX / VS Code Marketplace publisher).

License

MIT License


Quality & Security

Tests OpenSSF Scorecard Python versions

  • Tests — GitHub Actions test workflow status (runs on every push / PR)
  • OpenSSF Scorecard — supply-chain security posture
  • Python versions — supported runtime compatibility (declared in pyproject.toml)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_intervention_agent-1.8.6.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_intervention_agent-1.8.6-py3-none-any.whl (3.5 MB view details)

Uploaded Python 3

File details

Details for the file ai_intervention_agent-1.8.6.tar.gz.

File metadata

  • Download URL: ai_intervention_agent-1.8.6.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ai_intervention_agent-1.8.6.tar.gz
Algorithm Hash digest
SHA256 c35e8558c83e08f2fc2059301bc06df274ec402b0303c3aca7d5a83d813dc8c2
MD5 c07e0ba3ef17c4f47d9cb7e91bb0b125
BLAKE2b-256 680daa1184d6566e0f9d18d1026e2268a0884a4d8222e41b9c3f2332fd7bb39c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_intervention_agent-1.8.6.tar.gz:

Publisher: release.yml on XIADENGMA/ai-intervention-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_intervention_agent-1.8.6-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_intervention_agent-1.8.6-py3-none-any.whl
Algorithm Hash digest
SHA256 234c9a07417f3d296730fffcfebfa8e2b40e04bfeaaac69cd8af0a4439d8cb38
MD5 00b8ab08f2dc1a99a8e5315a770d1698
BLAKE2b-256 e807c14d8de8177c45c788e9b4435ad81c7f9cc0709abbc2cb35fb1b99d7e0dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_intervention_agent-1.8.6-py3-none-any.whl:

Publisher: release.yml on XIADENGMA/ai-intervention-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.8.9

2 files

1.8.8

2 files

1.8.7

2 files

This release

1.8.6 This release

2 files

1.8.3

2 files

1.8.2

2 files

1.7.13

2 files

1.7.11

2 files

1.7.9

2 files

1.7.8

2 files

1.7.7

2 files

1.7.6

2 files

1.7.4

2 files

1.7.3

2 files

1.7.2

2 files

1.6.4

2 files

1.6.3

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.36

2 files

1.5.35

2 files

1.5.34

2 files

1.5.33

2 files

1.5.26

2 files

1.5.25

2 files

1.5.24

2 files

1.5.22

2 files

1.5.19

2 files

1.5.18

2 files

1.5.17

2 files

1.5.15

2 files

1.5.13

2 files

1.5.9

2 files

1.5.8

2 files

1.5.6

2 files

1.5.5

2 files

1.5.4

2 files

1.5.3

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.17

2 files

1.4.16

2 files

1.4.15

2 files

1.4.14

2 files

1.4.13

2 files

1.4.12

2 files

1.4.10

2 files

1.4.9

2 files

1.4.8

2 files

1.4.7

2 files

1.4.6

2 files

1.4.5

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.3.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page