Skip to content

armgit / ARES

Public Imported from GitHub
0

ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.

feat(mcp): implement OpenClaw-style two-pane split terminal monitor

Mafifrizi5ded621e73c8
diff --git a/README.md b/README.md
index 337f82b..1f26255 100644
--- a/README.md
+++ b/README.md
@@ -410,32 +410,25 @@ ARES provides a production-grade **Model Context Protocol (MCP)** Gateway that e
<div align="center">
-![ARES MCP Interactive Console](docs/assets/screenshots/mcp-console.png)
+![ARES MCP Two-Pane Terminal Monitor](docs/assets/screenshots/mcp-console.png)
-*ARES MCP Interactive Terminal Console (OpenCode/OpenClaw style) with ScopeGuard protection and 1-click AI IDE setup.*
+*ARES MCP Two-Pane Split Terminal Monitor (OpenClaw style) with real-time tool telemetry, live scope inspection, and 1-key token authorization.*
</div>
Unlike basic MCP servers that expose raw endpoints to LLMs without guardrails, ARES enforces strict **Pre-Flight Scope Invariance (`ScopeGuard`)**, **Anti-Prompt-Injection Taint Isolation**, and **Single-Use 60-second HMAC Confirmation Tokens** before any live offensive action can execute.
-### πŸš€ Where Do I Start First? (5 Quick Steps)
+### πŸš€ Where Do I Start First? (Step-by-Step Onboarding)
For operators or developers connecting Cursor, Claude Desktop, or Windsurf to ARES:
-1. **Open a Terminal in the ARES Repository**:
- Launch the interactive ARES MCP console:
- ```powershell
- .\mcp.bat
- ```
- *(Note: In Windows PowerShell, prefix with `.\` or use the native script `.\mcp`)*.
-
-2. **Verify Subsystem Readiness (`doctor`)**:
- Ensure all 6 core subsystems (Protocol Engine, 9 Tools, 3 Resources, 3 Prompts, 62 Modules, Security Gates) report `PASS`:
+1. **Verify Subsystem Readiness (`doctor`)**:
+ Ensure all core subsystems (Protocol Engine, 9 Tools, 3 Resources, 3 Prompts, 62 Modules, Security Gates) report `PASS`:
```powershell
.\mcp.bat doctor
```
-3. **1-Click AI Client Setup (No Manual JSON Editing)**:
+2. **1-Click AI Client Setup (No Manual JSON Editing)**:
Automatically configure your preferred IDE with a single command:
```powershell
# For Cursor IDE:
@@ -452,14 +445,23 @@ For operators or developers connecting Cursor, Claude Desktop, or Windsurf to AR
```
This writes your active Python virtual environment path directly into the client config file (e.g. `.cursor/mcp.json`).
-4. **Reload Window in Cursor IDE**:
+3. **Reload Window in Cursor IDE**:
- In Cursor, press `Ctrl + Shift + P`.
- Select **`Developer: Reload Window`**.
- Open **Settings** (`Ctrl + ,`) &rarr; **Features** &rarr; **MCP Servers**. The **`ares`** server will show a green dot (`Connected`).
+4. **Launch the Live Two-Pane Monitor (Optional Companion Window)**:
+ In a dedicated terminal window, run the OpenClaw-style two-pane monitor to watch real-time AI tool invocations, scope checks, and approve tokens:
+ ```powershell
+ .\mcp.bat monitor
+ ```
+ - **Left Pane**: Live stream of tool calls executed by the AI agent (`ares_scope_check`, `ares_dry_run_module`, `ares_run_tool`).
+ - **Right Pane**: ScopeGuard CIDR boundaries, staged action diffs, and the **Authorization Gateway**.
+ - **Controls**: Press **`A`** to approve a pending execution token, **`R`** to reject, **`C`** to clear stream, **`Q`** to quit.
+
5. **Issue Your First Command to the AI Agent**:
Open Cursor Composer / Chat (`Ctrl + I` or `Ctrl + L`), and try this prompt:
- > *"Check active campaign status and list recent vulnerability findings using the ARES MCP tools."*
+ > *"Check active campaign status, verify scope for target 10.0.1.50, and stage a dry-run of module ad_kerberoast."*
For in-depth architecture, the 7 security invariants, CLI scriptability (`--json`), POSIX exit codes, and operational tool schemas, see [**ARES MCP Gateway & Product-Grade CLI Specification**](docs/mcp-server.md).
diff --git a/ares/cli/console.py b/ares/cli/console.py
index fe830f5..af8360b 100644
--- a/ares/cli/console.py
+++ b/ares/cli/console.py
@@ -406,6 +406,8 @@ def interactive_console_loop() -> None:
f"[{COLOR_NEUTRAL}]Verify subsystem readiness matrix[/]",
f" [{COLOR_INDEX}][6][/] [{COLOR_VALUE}]HTTP / SSE Gateway[/] "
f"[{COLOR_NEUTRAL}]Start local network server (Port 8001)[/]",
+ f" [{COLOR_INDEX}][7][/] [{COLOR_VALUE}]Live TUI Monitor (OpenClaw)[/] "
+ f"[{COLOR_NEUTRAL}]Two-Pane real-time telemetry & token approval[/]",
f" [{COLOR_ERROR}][0][/] [{COLOR_ERROR}]Exit[/]",
]
console.print(Panel(
@@ -417,7 +419,7 @@ def interactive_console_loop() -> None:
choice = Prompt.ask(
f"[{COLOR_LABEL}]Select option[/]",
- choices=["1", "2", "3", "4", "5", "6", "0"],
+ choices=["1", "2", "3", "4", "5", "6", "7", "0"],
default="1",
)
@@ -438,6 +440,9 @@ def interactive_console_loop() -> None:
run_system_doctor()
elif choice == "6":
start_sse_server()
+ elif choice == "7":
+ from ares.cli.mcp_tui import run_mcp_monitor
+ run_mcp_monitor()
except KeyboardInterrupt:
console.print(f"\n[{COLOR_NEUTRAL}]Cancelled[/]")
diff --git a/ares/cli/mcp_tui.py b/ares/cli/mcp_tui.py
new file mode 100644
index 0000000..4e37947
--- /dev/null
+++ b/ares/cli/mcp_tui.py
@@ -0,0 +1,425 @@
+"""
+ARES MCP Two-Pane Split Terminal User Interface (OpenClaw Style).
+Provides real-time, zero-emoji telemetry and interactive confirmation token authorization.
+"""
+from __future__ import annotations
+
+import sys
+import threading
+import time
+from typing import Any, Dict, List, Optional
+
+# Non-blocking keyboard check
+try:
+ import msvcrt
+
+ def check_keypress() -> Optional[str]:
+ if msvcrt.kbhit():
+ ch = msvcrt.getch()
+ try:
+ return ch.decode("utf-8").lower()
+ except UnicodeDecodeError:
+ return None
+ return None
+
+except ImportError:
+ import select
+
+ def check_keypress() -> Optional[str]:
+ r, _, _ = select.select([sys.stdin], [], [], 0)
+ if r:
+ ch = sys.stdin.read(1)
+ return ch.lower()
+ return None
+
+from rich import box
+from rich.console import Console, Group
+from rich.layout import Layout
+from rich.live import Live
+from rich.panel import Panel
+from rich.table import Table
+from rich.text import Text
+
+from ares.mcp.events import McpEventBus, McpEventListener
+
+
+class TuiState:
+ """Operational state for the ARES MCP Two-Pane Split TUI."""
+
+ def __init__(self, campaign: str = "Internal-Audit-2026", scope: str = "10.0.1.0/24, 192.168.10.0/24") -> None:
+ self.events: List[Dict[str, Any]] = []
+ self.campaign_name: str = campaign
+ self.scope_cidrs: str = scope
+ self.strict_mode: bool = True
+ self.opsec_profile: str = "STEALTH (Jitter: 2.5s)"
+
+ # Staged action state
+ self.staged_module: Optional[str] = None
+ self.staged_target: Optional[str] = None
+ self.staged_action: Optional[str] = None
+ self.staged_risk: Optional[str] = None
+
+ # Pending authorization token
+ self.pending_token: Optional[str] = None
+ self.token_module: Optional[str] = None
+ self.token_expiry: float = 0.0
+ self.token_status: str = "IDLE" # IDLE, PENDING, APPROVED, REJECTED, EXPIRED
+
+ def add_event(self, timestamp: str, event_type: str, details: str, status: str, status_style: str = "green") -> None:
+ self.events.append({
+ "time": timestamp,
+ "type": event_type,
+ "details": details,
+ "status": status,
+ "status_style": status_style,
+ })
+ if len(self.events) > 100:
+ self.events.pop(0)
+
+ def set_pending_token(self, token: str, module: str, ttl_seconds: int = 60) -> None:
+ self.pending_token = token
+ self.token_module = module
+ self.token_expiry = time.time() + ttl_seconds
+ self.token_status = "PENDING"
+
+ def approve_token(self) -> Optional[str]:
+ if self.pending_token and self.token_status == "PENDING":
+ self.token_status = "APPROVED"
+ token = self.pending_token
+ return token
+ return None
+
+ def reject_token(self) -> Optional[str]:
+ if self.pending_token and self.token_status == "PENDING":
+ self.token_status = "REJECTED"
+ token = self.pending_token
+ return token
+ return None
+
+
+def build_tui_layout(state: TuiState) -> Layout:
+ """Build the root Two-Pane Split Layout (OpenClaw style)."""
+ root = Layout(name="root")
+ root.split_column(
+ Layout(name="header", size=3),
+ Layout(name="body", ratio=1),
+ Layout(name="footer", size=3),
+ )
+
+ root["body"].split_row(
+ Layout(name="left_stream", ratio=6),
+ Layout(name="right_posture", ratio=4),
+ )
+
+ # 1. Header: Minimalist single-line metadata bar
+ header_text = Text.assemble(
+ (" ARES MCP ", "bold black on cyan"),
+ (" GATEWAY LISTENING ", "bold white"),
+ ("| TRANSPORT: ", "dim"),
+ ("stdio / sse", "cyan"),
+ (" | CAMPAIGN: ", "dim"),
+ (state.campaign_name, "bold white"),
+ (" | SCOPE: ", "dim"),
+ (state.scope_cidrs.split(",")[0], "bold yellow"),
+ )
+ root["header"].update(
+ Panel(header_text, box=box.ROUNDED, style="dim white")
+ )
+
+ # 2. Left Stream: Chronological MCP Tool Invocations
+ stream_table = Table(
+ box=None,
+ show_header=True,
+ header_style="bold dim white",
+ expand=True,
+ pad_edge=False,
+ )
+ stream_table.add_column("TIME", width=9, style="dim white")
+ stream_table.add_column("EVENT", width=9)
+ stream_table.add_column("DETAILS", ratio=1)
+ stream_table.add_column("STATUS", width=22, justify="right")
+
+ visible_events = state.events[-15:] if state.events else []
+ if not visible_events:
+ stream_table.add_row(
+ time.strftime("%H:%M:%S"),
+ Text("[INIT]", style="dim cyan"),
+ Text("Gateway ready. Waiting for AI client tool calls...", style="dim white"),
+ Text("[IDLE]", style="dim green"),
+ )
+ else:
+ for ev in visible_events:
+ type_style = "bold cyan"
+ if ev["type"] == "AUTH":
+ type_style = "bold yellow"
+ elif ev["type"] == "WARN":
+ type_style = "bold red"
+
+ stream_table.add_row(
+ ev["time"],
+ Text(f"[{ev['type']}]", style=type_style),
+ Text(ev["details"], style="white"),
+ Text(f"[{ev['status']}]", style=f"bold {ev['status_style']}"),
+ )
+
+ root["left_stream"].update(
+ Panel(
+ stream_table,
+ title="[bold white]ARES MCP LIVE STREAM[/bold white]",
+ subtitle="[dim]Real-time tool invocations by LLM[/dim]",
+ box=box.ROUNDED,
+ style="white",
+ )
+ )
+
+ # 3. Right Posture: Scope, Staged Dry-Run, and Authorization Gateway
+ right_elements = []
+
+ # Section A: Active Campaign & Scope
+ scope_table = Table(box=None, show_header=False, expand=True, pad_edge=False)
+ scope_table.add_column("Key", width=14, style="dim white")
+ scope_table.add_column("Val", style="bold white")
+ scope_table.add_row("Campaign", state.campaign_name)
+ scope_table.add_row("Scope CIDRs", state.scope_cidrs)
+ scope_table.add_row("ScopeGuard", "ENFORCED (Strict Mode)" if state.strict_mode else "PERMISSIVE")
+ scope_table.add_row("OPSEC Profile", state.opsec_profile)
+
+ right_elements.append(
+ Panel(
+ scope_table,
+ title="[bold white]TARGET & GOVERNANCE POSTURE[/bold white]",
+ box=box.ROUNDED,
+ style="dim white",
+ )
+ )
+
+ # Section B: Staged Action (Dry-Run Preview)
+ staged_table = Table(box=None, show_header=False, expand=True, pad_edge=False)
+ staged_table.add_column("Key", width=14, style="dim white")
+ staged_table.add_column("Val", style="bold white")
+ if state.staged_module:
+ staged_table.add_row("Module", state.staged_module)
+ staged_table.add_row("Target", state.staged_target or "-")
+ staged_table.add_row("Action", state.staged_action or "-")
+ staged_table.add_row("Noise Risk", state.staged_risk or "LOW")
+ else:
+ staged_table.add_row("State", "[dim]No active dry-run staged[/dim]")
+ staged_table.add_row("Safety", "Zero pending executions")
+
+ right_elements.append(
+ Panel(
+ staged_table,
+ title="[bold white]STAGED ACTIONS (DRY-RUN)[/bold white]",
+ box=box.ROUNDED,
+ style="dim white",
+ )
+ )
+
+ # Section C: Authorization Gateway (Confirmation Token)
+ auth_table = Table(box=None, show_header=False, expand=True, pad_edge=False)
+ auth_table.add_column("Key", width=14, style="dim white")
+ auth_table.add_column("Val")
+
+ if state.token_status == "PENDING":
+ remaining = max(0, int(state.token_expiry - time.time()))
+ if remaining == 0:
+ state.token_status = "EXPIRED"
+
+ if state.token_status == "PENDING":
+ remaining = max(0, int(state.token_expiry - time.time()))
+ auth_table.add_row("Status", Text("WAITING OPERATOR CONFIRMATION", style="bold yellow"))
+ auth_table.add_row("Token", Text(f"#{state.pending_token}", style="bold white on yellow"))
+ auth_table.add_row("Module", Text(str(state.token_module), style="cyan"))
+ auth_table.add_row("Expires In", Text(f"{remaining}s remaining", style="bold yellow"))
+ auth_table.add_row("Controls", Text("Press [A] to Approve | [R] to Reject", style="bold green"))
+ auth_panel_style = "bold yellow"
+ elif state.token_status == "APPROVED":
+ auth_table.add_row("Status", Text("APPROVED BY OPERATOR", style="bold green"))
+ auth_table.add_row("Token", Text(f"#{state.pending_token} (Consumed)", style="dim white"))
+ auth_table.add_row("State", Text("Execution signal dispatched to MCP", style="green"))
+ auth_panel_style = "bold green"
+ elif state.token_status == "REJECTED":
+ auth_table.add_row("Status", Text("REJECTED / ABORTED BY OPERATOR", style="bold red"))
+ auth_table.add_row("Token", Text(f"#{state.pending_token} (Revoked)", style="dim white"))
+ auth_table.add_row("State", Text("Execution blocked. Returned error to client.", style="red"))
+ auth_panel_style = "bold red"
+ elif state.token_status == "EXPIRED":
+ auth_table.add_row("Status", Text("TOKEN EXPIRED (TTL Elapsed)", style="dim red"))
+ auth_table.add_row("Token", Text(f"#{state.pending_token} (Invalidated)", style="dim white"))
+ auth_panel_style = "dim red"
+ else:
+ auth_table.add_row("Status", Text("IDLE | No pending authorization", style="dim green"))
+ auth_table.add_row("ScopeGuard", Text("All live mutations require confirmation token", style="dim white"))
+ auth_panel_style = "dim white"
+
+ right_elements.append(
+ Panel(
+ auth_table,
+ title="[bold white]AUTHORIZATION GATEWAY[/bold white]",
+ box=box.ROUNDED,
+ style=auth_panel_style,
+ )
+ )
+
+ root["right_posture"].update(Group(*right_elements))
+
+ # 4. Footer: Keybindings statusline
+ footer_text = Text.assemble(
+ (" [A] ", "bold green"),
+ ("Approve Token ", "white"),
+ ("[R] ", "bold red"),
+ ("Reject Token ", "white"),
+ ("[C] ", "bold cyan"),
+ ("Clear Stream ", "white"),
+ ("[Q] ", "bold white"),
+ ("Quit Monitor ", "dim white"),
+ (" [Transport: Local UDP Port 27890]", "dim"),
+ )
+ root["footer"].update(
+ Panel(footer_text, box=box.ROUNDED, style="dim white")
+ )
+
+ return root
+
+
+def run_demo_feeder(state: TuiState) -> None:
+ """Dispatches realistic automated events for demo testing."""
+ time.sleep(1.0)
+ McpEventBus.emit("CALL", {
+ "call": "ares_list_campaigns()",
+ "status": "OK: 1 active",
+ "style": "green",
+ })
+ time.sleep(1.8)
+
+ McpEventBus.emit("CALL", {
+ "call": "ares_scope_check(target=10.0.1.50)",
+ "status": "ALLOW: in-scope",
+ "style": "green",
+ })
+ time.sleep(1.5)
+
+ McpEventBus.emit("CALL", {
+ "call": "ares_scope_check(target=8.8.8.8)",
+ "status": "BLOCKED: out-of-scope",
+ "style": "red",
+ })
+ time.sleep(2.0)
+
+ McpEventBus.emit("STAGED", {
+ "call": "ares_dry_run_module(module=ad_kerberoast)",
+ "module": "ad_kerberoast",
+ "target": "DC01.corp.local (10.0.1.10)",
+ "action": "LDAP SPN Query & TGS-REQ Request",
+ "risk": "MEDIUM (Noise: 2.5s jitter)",
+ "status": "STAGED",
+ "style": "blue",
+ })
+ time.sleep(2.0)
+
+ token = "d8a1f4"
+ McpEventBus.emit("AUTH", {
+ "call": f"Token issued for ad_kerberoast: #{token}",
+ "token": token,
+ "module": "ad_kerberoast",
+ "ttl": 60,
+ "status": "PENDING: 60s",
+ "style": "yellow",
+ })
+
+
+def run_mcp_monitor(campaign: str = "Internal-Audit-2026", scope: str = "10.0.1.0/24", demo: bool = False) -> int:
+ """Main execution loop for ARES MCP Two-Pane TUI Monitor."""
+ console = Console()
+ state = TuiState(campaign=campaign, scope=scope)
+ listener = McpEventListener()
+
+ if demo:
+ t = threading.Thread(target=run_demo_feeder, args=(state,), daemon=True)
+ t.start()
+
+ console.clear()
+
+ try:
+ with Live(build_tui_layout(state), console=console, screen=True, refresh_per_second=10) as live:
+ while True:
+ # 1. Process keyboard events
+ key = check_keypress()
+ if key == "q":
+ break
+ elif key == "c":
+ state.events.clear()
+ elif key == "a":
+ approved = state.approve_token()
+ if approved:
+ McpEventBus.set_token_decision(approved, "APPROVED")
+ state.add_event(
+ time.strftime("%H:%M:%S"),
+ "AUTH",
+ f"Operator approved execution token #{approved}",
+ "APPROVED",
+ "green",
+ )
+ elif key == "r":
+ rejected = state.reject_token()
+ if rejected:
+ McpEventBus.set_token_decision(rejected, "REJECTED")
+ state.add_event(
+ time.strftime("%H:%M:%S"),
+ "AUTH",
+ f"Operator rejected execution token #{rejected}",
+ "REJECTED",
+ "red",
+ )
+
+ # 2. Poll incoming events from UDP listener
+ incoming = listener.poll_events()
+ for ev in incoming:
+ ev_type = ev.get("type", "INFO")
+ data = ev.get("data", {})
+ ts = ev.get("timestamp", time.strftime("%H:%M:%S"))
+
+ if ev_type == "CALL":
+ state.add_event(
+ ts,
+ "CALL",
+ data.get("call", ""),
+ data.get("status", "OK"),
+ data.get("style", "green"),
+ )
+ elif ev_type == "STAGED":
+ state.staged_module = data.get("module")
+ state.staged_target = data.get("target")
+ state.staged_action = data.get("action")
+ state.staged_risk = data.get("risk")
+ state.add_event(
+ ts,
+ "CALL",
+ data.get("call", ""),
+ data.get("status", "STAGED"),
+ data.get("style", "blue"),
+ )
+ elif ev_type == "AUTH":
+ token = data.get("token", "none")
+ module = data.get("module", "unknown")
+ ttl = int(data.get("ttl", 60))
+ state.set_pending_token(token, module, ttl)
+ state.add_event(
+ ts,
+ "AUTH",
+ data.get("call", f"Token #{token} pending"),
+ data.get("status", "PENDING"),
+ data.get("style", "yellow"),
+ )
+
+ # 3. Update rendered layout
+ live.update(build_tui_layout(state))
+ time.sleep(0.08)
+
+ except KeyboardInterrupt:
+ pass
+ finally:
+ listener.close()
+
+ console.print("\n[dim]ARES MCP Terminal Monitor terminated cleanly.[/dim]")
+ return 0
diff --git a/ares/cli/typer_main.py b/ares/cli/typer_main.py
index 3fd06ee..71ff31e 100644
--- a/ares/cli/typer_main.py
+++ b/ares/cli/typer_main.py
@@ -2751,6 +2751,23 @@ def mcp_console_cmd() -> None:
raise typer.Exit(130)
+@mcp_app.command("monitor")
+@mcp_app.command("tui")
+def mcp_monitor_cmd(
+ campaign: str = typer.Option("Internal-Audit-2026", "--campaign", "-c", help="Active campaign name to monitor"),
+ scope: str = typer.Option("10.0.1.0/24, 192.168.10.0/24", "--scope", "-s", help="Approved CIDRs scope"),
+ demo: bool = typer.Option(False, "--demo", help="Run automated demonstration telemetry feed"),
+) -> None:
+ """Launch the ARES MCP Two-Pane Split Terminal Monitor (OpenClaw style)."""
+ from ares.cli.mcp_tui import run_mcp_monitor
+ try:
+ code = run_mcp_monitor(campaign=campaign, scope=scope, demo=demo)
+ raise typer.Exit(code)
+ except KeyboardInterrupt:
+ console.print("\n[dim]Cancelled[/dim]")
+ raise typer.Exit(130)
+
+
@app.command("console")
def app_console_cmd() -> None:
"""Launch the ARES MCP Interactive Console (OpenCode/OpenClaw style)."""
@@ -2762,6 +2779,22 @@ def app_console_cmd() -> None:
raise typer.Exit(130)
+def app_monitor_cmd(
+ campaign: str = typer.Option("Internal-Audit-2026", "--campaign", "-c", help="Active campaign name to monitor"),
+ scope: str = typer.Option("10.0.1.0/24, 192.168.10.0/24", "--scope", "-s", help="Approved CIDRs scope"),
+ demo: bool = typer.Option(False, "--demo", help="Run automated demonstration telemetry feed"),
+) -> None:
+ """Launch the ARES MCP Two-Pane Split Terminal Monitor (OpenClaw style)."""
+ from ares.cli.mcp_tui import run_mcp_monitor
+ try:
+ code = run_mcp_monitor(campaign=campaign, scope=scope, demo=demo)
+ raise typer.Exit(code)
+ except KeyboardInterrupt:
+ console.print("\n[dim]Cancelled[/dim]")
+ raise typer.Exit(130)
+
+
@mcp_app.command("doctor")
def mcp_doctor_cmd(
json_output: bool = typer.Option(False, "--json", help="Output machine-readable JSON status"),
diff --git a/ares/mcp/events.py b/ares/mcp/events.py
new file mode 100644
index 0000000..1223cf8
--- /dev/null
+++ b/ares/mcp/events.py
@@ -0,0 +1,109 @@
+"""
+ARES MCP Event Bus.
+Provides sub-millisecond, non-blocking UDP loopback event telemetry
+between the MCP stdio/SSE server and local TUI terminal monitors.
+"""
+from __future__ import annotations
+
+import json
+import socket
+import time
+from pathlib import Path
+from typing import Any, Dict, List, Optional
+
+DEFAULT_EVENT_PORT = 27890
+DEFAULT_EVENT_HOST = "127.0.0.1"
+TOKEN_STATUS_FILE = Path.home() / ".ares" / "mcp_token_status.json"
+
+
+class McpEventBus:
+ """Non-blocking event emitter for MCP server telemetry."""
+
+ @staticmethod
+ def emit(event_type: str, data: Dict[str, Any]) -> None:
+ """Emit telemetry event to local monitor over UDP loopback."""
+ payload = {
+ "timestamp": time.strftime("%H:%M:%S"),
+ "type": event_type,
+ "data": data,
+ }
+ try:
+ raw = json.dumps(payload).encode("utf-8")
+ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ sock.sendto(raw, (DEFAULT_EVENT_HOST, DEFAULT_EVENT_PORT))
+ sock.close()
+ except Exception:
+ pass # Silent drop if no listener or network exception
+
+ @staticmethod
+ def set_token_decision(token: str, decision: str) -> None:
+ """Record operator decision (APPROVED or REJECTED) for a token."""
+ TOKEN_STATUS_FILE.parent.mkdir(parents=True, exist_ok=True)
+ payload = {
+ "token": token,
+ "decision": decision,
+ "timestamp": time.strftime("%H:%M:%S"),
+ }
+ try:
+ with open(TOKEN_STATUS_FILE, "w", encoding="utf-8") as f:
+ json.dump(payload, f, indent=2)
+ except Exception:
+ pass
+
+ @staticmethod
+ def get_token_decision(token: str) -> Optional[str]:
+ """Read operator decision for a token."""
+ if not TOKEN_STATUS_FILE.exists():
+ return None
+ try:
+ with open(TOKEN_STATUS_FILE, "r", encoding="utf-8") as f:
+ data = json.load(f)
+ if data.get("token") == token:
+ return data.get("decision")
+ except Exception:
+ pass
+ return None
+
+
+class McpEventListener:
+ """Non-blocking UDP receiver for terminal monitor."""
+
+ def __init__(self, host: str = DEFAULT_EVENT_HOST, port: int = DEFAULT_EVENT_PORT) -> None:
+ self.host = host
+ self.port = port
+ self.sock: Optional[socket.socket] = None
+ self._bind()
+
+ def _bind(self) -> None:
+ try:
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+ self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ self.sock.bind((self.host, self.port))
+ self.sock.setblocking(False)
+ except Exception:
+ self.sock = None
+
+ def poll_events(self) -> List[Dict[str, Any]]:
+ """Poll incoming UDP events without blocking."""
+ events: List[Dict[str, Any]] = []
+ if not self.sock:
+ return events
+
+ while True:
+ try:
+ data, _ = self.sock.recvfrom(65535)
+ event = json.loads(data.decode("utf-8"))
+ events.append(event)
+ except (BlockingIOError, socket.error):
+ break
+ except Exception:
+ break
+ return events
+
+ def close(self) -> None:
+ if self.sock:
+ try:
+ self.sock.close()
+ except Exception:
+ pass
+ self.sock = None
diff --git a/ares/mcp/security.py b/ares/mcp/security.py
index c2f3e98..f63ad89 100644
--- a/ares/mcp/security.py
+++ b/ares/mcp/security.py
@@ -68,6 +68,21 @@ class ConfirmationTokenManager:
expires_at = time.time() + ttl_seconds
self._tokens[token] = (expires_at, payload)
self._purge_expired()
+
+ try:
+ from ares.mcp.events import McpEventBus
+ McpEventBus.emit("AUTH", {
+ "call": f"Token issued for {module_id}: #{token[:16]}",
+ "token": token,
+ "module": module_id,
+ "target": target,
+ "ttl": int(ttl_seconds),
+ "status": f"PENDING: {int(ttl_seconds)}s",
+ "style": "yellow",
+ })
+ except Exception:
+ pass
+
return token
def validate_and_burn(
@@ -88,6 +103,15 @@ class ConfirmationTokenManager:
self._tokens.pop(token, None)
return False
+ # Honor operator reject decision from TUI monitor
+ try:
+ from ares.mcp.events import McpEventBus
+ if McpEventBus.get_token_decision(token) == "REJECTED":
+ self._tokens.pop(token, None)
+ return False
+ except Exception:
+ pass
+
actual_payload = self._make_payload(campaign_id, module_id, target, params)
if hmac.compare_digest(expected_payload, actual_payload):
self._tokens.pop(token, None) # Burn upon valid use (anti-replay)
diff --git a/ares/mcp/server.py b/ares/mcp/server.py
index 0f5569f..b1b175b 100644
--- a/ares/mcp/server.py
+++ b/ares/mcp/server.py
@@ -8,6 +8,7 @@ from __future__ import annotations
import logging
from typing import Any, Callable, Coroutine
+from ares.mcp.events import McpEventBus
from ares.mcp.prompts import McpPromptRegistry
from ares.mcp.protocol import (
ErrorCode,
@@ -111,6 +112,26 @@ class AresMcpServer:
).model_dump(exclude_none=True)
res = await self.tool_registry.call_tool(tool_name, tool_args)
+
+ # Emit real-time telemetry to local ARES MCP TUI Monitor
+ try:
+ arg_summary = ", ".join(f"{k}={v}" for k, v in list(tool_args.items())[:2])
+ status_label = "ERROR" if res.isError else "OK"
+ status_style = "red" if res.isError else "green"
+ if "scope" in tool_name:
+ status_label = "BLOCKED: out-of-scope" if res.isError else "ALLOW: in-scope"
+ elif "dry_run" in tool_name:
+ status_label = "STAGED"
+ status_style = "blue"
+
+ McpEventBus.emit("CALL", {
+ "call": f"{tool_name}({arg_summary})",
+ "status": status_label,
+ "style": status_style,
+ })
+ except Exception:
+ pass
+
return JSONRPCResponse(id=req.id, result=res.model_dump()).model_dump(exclude_none=True)
# Resources
diff --git a/ares/mcp/tools.py b/ares/mcp/tools.py
index 231a650..ab1080b 100644
--- a/ares/mcp/tools.py
+++ b/ares/mcp/tools.py
@@ -478,7 +478,7 @@ class McpToolRegistry:
ttl_seconds=60.0,
)
- # 4. Broadcast Simulation Event to WebSocket Live Dashboard
+ # 4. Broadcast Simulation Event to WebSocket Live Dashboard & Local TUI Monitor
await self._broadcast(
campaign_id,
{
@@ -489,6 +489,19 @@ class McpToolRegistry:
"status": "simulation_ready",
},
)
+ try:
+ from ares.mcp.events import McpEventBus
+ McpEventBus.emit("STAGED", {
+ "call": f"ares_dry_run_module(module={module_id})",
+ "module": module_id,
+ "target": target,
+ "action": descriptor.description[:40] if descriptor.description else "Dry-Run Simulation",
+ "risk": f"{descriptor.opsec.value.upper()} (Safe Pre-flight)",
+ "status": "STAGED",
+ "style": "blue",
+ })
+ except Exception:
+ pass
simulation_result = {
"status": "SIMULATION_SUCCESS",
diff --git a/docs/assets/screenshots/mcp-console.png b/docs/assets/screenshots/mcp-console.png
index ee55c82..63c43e2 100644
Binary files a/docs/assets/screenshots/mcp-console.png and b/docs/assets/screenshots/mcp-console.png differ
diff --git a/docs/assets/screenshots/mcp-monitor.png b/docs/assets/screenshots/mcp-monitor.png
new file mode 100644
index 0000000..63c43e2
Binary files /dev/null and b/docs/assets/screenshots/mcp-monitor.png differ
diff --git a/docs/mcp-server.md b/docs/mcp-server.md
index ce0896c..6d98b02 100644
--- a/docs/mcp-server.md
+++ b/docs/mcp-server.md
@@ -8,9 +8,9 @@
<div align="center">
-![ARES MCP Interactive Console](assets/screenshots/mcp-console.png)
+![ARES MCP Two-Pane Terminal Monitor](assets/screenshots/mcp-console.png)
-*ARES MCP Interactive Terminal Console (OpenCode/OpenClaw style) with ScopeGuard protection and 1-click client configuration.*
+*ARES MCP Two-Pane Split Terminal Monitor (OpenClaw style) with real-time tool telemetry, live scope inspection, and 1-key token authorization.*
</div>
@@ -30,7 +30,7 @@ Unlike basic MCP servers that blindly expose raw shell execution or dangerous en
## 2. πŸš€ Step-by-Step Guide: Where Do I Start First?
-For operators or developers getting started with ARES MCP for the first time, follow these 5 guided steps:
+For operators or developers getting started with ARES MCP for the first time, follow these 6 guided steps:
### Step 1: Ensure Your Python Virtual Environment Is Ready
Open a PowerShell or terminal prompt in the root of the ARES repository:
@@ -49,7 +49,7 @@ Run the `mcp.bat` launcher (or `mcp.ps1` in PowerShell):
# Or using the native PowerShell script:
.\mcp
```
-An OpenCode / OpenClaw-style interactive console will open, displaying system health, 62 active attack modules, 9 registered operational tools, and options `[1]` through `[0]`.
+An OpenCode / OpenClaw-style interactive console will open, displaying system health, 62 active attack modules, 9 registered operational tools, and options `[1]` through `[7]`.
### Step 3: Run the Subsystem Healthcheck (`doctor`)
Before connecting any AI client, verify that all core subsystems are fully operational:
@@ -89,11 +89,20 @@ This command automatically writes the correct absolute Python virtual environmen
4. Navigate to **Features** &rarr; **MCP Servers**.
5. The **`ares`** server will appear with a **green status indicator** (`Connected`) and 9 available tools.
-### Step 6: Issue Your First Command to the AI Agent
+### Step 6: Launch the Live Two-Pane Monitor (Companion Terminal)
+In a second terminal window side-by-side with your IDE, launch the real-time Two-Pane Monitor:
+```powershell
+.\mcp.bat monitor
+```
+- **Left Pane (60%)**: Displays live tool invocations as the AI agent calls them (`ares_scope_check`, `ares_dry_run_module`, etc.).
+- **Right Pane (40%)**: Displays real-time scope rules, staged actions, and the **Authorization Gateway**.
+- **Interactive Controls**: When a dangerous action requires confirmation, press **`A`** to approve or **`R`** to reject. Press **`C`** to clear stream, **`Q`** to quit.
+
+### Step 7: Issue Your First Command to the AI Agent
Open **Cursor Composer / Chat** (`Ctrl + I` or `Ctrl + L`), and try asking:
-> *"Check the active campaigns and list recent vulnerability findings using the ARES MCP tools."*
+> *"Check active campaign status, verify scope for target 10.0.1.50, and stage a dry-run of module ad_kerberoast."*
-The AI Agent will call `ares_list_campaigns` and render the engagement data directly inside your editor.
+The AI Agent will call `ares_scope_check` and `ares_dry_run_module`, streaming results directly to both your editor and your live terminal monitor.
---
@@ -137,6 +146,7 @@ The ARES MCP CLI (`mcp.bat`, `mcp.ps1`, or `python -m ares.cli.main mcp`) is des
| Command | Description | Scriptable / JSON |
| :--- | :--- | :---: |
| `.\mcp.bat` | Launches the interactive OpenCode/OpenClaw-style TUI console. | TTY Auto-detect |
+| `.\mcp.bat monitor` | Launches the Two-Pane Split Terminal Monitor with live telemetry & 1-key token authorization. | Interactive TUI |
| `.\mcp.bat doctor` | Verifies readiness across all protocol, tools, and security gates. | Yes (`--json`) |
| `.\mcp.bat module-catalog` | Searches and filters 62 attack modules with OPSEC and governance metadata. | Yes (`--json`) |
| `.\mcp.bat scope-check` | Verifies whether a target IP, CIDR, or hostname is in authorized scope. | Yes (`--json`) |
diff --git a/tests/conftest.py b/tests/conftest.py
index 73131b5..77ad75a 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -36,7 +36,7 @@ os.environ.setdefault("ARES_DEFAULT_ADMIN_PASSWORD", "TestPassword1!")
def pytest_configure(config: pytest.Config) -> None:
"""Ensure tests run against a clean external basetemp outside _REPO_ROOT."""
if config.option.basetemp is None:
- target = Path(tempfile.gettempdir()) / "ares_pytest"
+ target = Path(tempfile.gettempdir()) / f"ares_pytest_{os.getpid()}"
target.mkdir(parents=True, exist_ok=True)
config.option.basetemp = str(target)
diff --git a/tests/unit/test_mcp_cli.py b/tests/unit/test_mcp_cli.py
index 78e6756..eb362ae 100644
--- a/tests/unit/test_mcp_cli.py
+++ b/tests/unit/test_mcp_cli.py
@@ -229,6 +229,9 @@ def test_mcp_non_interactive_piped() -> None:
def test_mcp_subcommand_help_coverage() -> None:
"""Verify comprehensive help is available on all MCP subcommands."""
subcommands = [
+ "console",
+ "monitor",
+ "tui",
"doctor",
"module-catalog",
"scope-check",
@@ -244,3 +247,13 @@ def test_mcp_subcommand_help_coverage() -> None:
result = runner.invoke(app, ["mcp", subcmd, "--help"])
assert result.exit_code == EXIT_SUCCESS, f"Subcommand {subcmd} failed help check"
assert "Usage:" in result.stdout or "Options" in result.stdout
+
+
+def test_mcp_monitor_options_help() -> None:
+ """Verify monitor subcommand flags --campaign, --scope, --demo are documented."""
+ result = runner.invoke(app, ["mcp", "monitor", "--help"])
+ assert result.exit_code == EXIT_SUCCESS
+ assert "--campaign" in result.stdout
+ assert "--scope" in result.stdout
+ assert "--demo" in result.stdout
+ assert "OpenClaw style" in result.stdout