aws / aws/amazon-q-developer-cli
Interactive Hook Support for User Confirmations
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
# 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.
Contributor guide
Assessment
This issue has not been assessed yet.