aws / aws/amazon-q-developer-cli

Interactive Hook Support for User Confirmations

Aperta
#3,159 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Feature request q chat
Lingua principale
Rust
Stelle
2k
Fork
439
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

# Feature Request: Interactive Hook Support for User Confirmations

## Summary
Add support for interactive hooks that can display confirmation prompts and informational messages to users before tool execution, enhancing the user experience for MCP servers that perform write operations.

## Problem Statement
Currently, PreToolUse hooks can validate and block tool execution, but cannot interact with users in a clean way:

• **Exit code 0**: STDOUT captured but not shown to user
• **Exit code 2**: Block execution, STDERR returned to LLM (not user)
• **Other codes**: STDERR shown as warning with potential confusing boilerplate

This limits MCP servers from providing user-friendly confirmation workflows for potentially destructive or important operations.

## Proposed Solution
Introduce two new exit codes for PreToolUse hooks:

### Exit Code 3: User Confirmation Required
• Hook returns exit code 3 with formatted confirmation prompt in STDOUT
• Q CLI displays the STDOUT content to the user as a confirmation dialog
• User confirms (y/n) or similar interaction
• Q CLI proceeds with tool execution if confirmed, blocks if denied

### Exit Code 4: Informational Display
• Hook returns exit code 4 with formatted informational message in STDOUT
• Q CLI displays the STDOUT content to the user (no confirmation required)
• Tool execution proceeds automatically after displaying the message

## Use Cases
• **GSE task management**: Confirm before creating/updating tasks, show task details
• **File operations**: Confirm before deleting files, show file information
• **Database operations**: Confirm before destructive queries, show query preview
• **Deployment tools**: Confirm before production deployment, show deployment summary

## Example Workflows

### Confirmation (Exit Code 3)
```bash
echo "📝 Ready to add comment to task"

\"MCP Tool Introspection Issue Identified...\"

🔗 Task: https://example.com/task-0123
👤 Assignee: Joe Blogs

Proceed? (y/n)"
exit 3
```

### Informational (Exit Code 4)
```bash
echo "📋 Creating task in task system:

📝 Title: Obsidian MCP Server Testing
🎯 Points: 3
exit 4
```

## Benefits
• Improved user experience for MCP servers performing write operations
• Flexible interaction: confirmations when needed, information when helpful
• Maintains security by allowing user oversight of potentially destructive actions
• Enables better integration between Q CLI and external systems
• Consistent UX across all MCP servers

## Current Workaround
MCP servers must format responses post-execution, which doesn't prevent unwanted operations and provides poor UX for confirmations.

## Impact
This enhancement would benefit all MCP server developers who want to implement confirmation workflows or provide better user feedback, improving the overall Q CLI ecosystem.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by tracing the existing PreToolUse hook handling in the Q CLI, especially how exit codes 0 and 2 route STDOUT and STDERR before tool execution. Define the confirmation and informational flows around exit codes 3 and 4, including user responses and denied execution. Done means the CLI displays the requested messages, proceeds or blocks correctly, and preserves existing hook behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
cli
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.