Require Human Confirmation for Trade Tools During Market Hours
A time-based governance rule: an order-execution tool that might be safe to auto-approve overnight (paper trading, backtests) gets downgraded to `ask` the moment it's called during live market hours, when the same call has real consequences.
1. Save this as the hook script
#!/usr/bin/env python3
"""PreToolUse hook — forces "ask" on an order/trade MCP tool during
9:30am-4pm ET. Wire to matcher "mcp__.*order.*|mcp__.*trade.*"."""
import json, sys, datetime
data = json.load(sys.stdin)
tool_name = data.get("tool_name", "")
hour = datetime.datetime.now().hour
MARKET_OPEN, MARKET_CLOSE = 9, 16
if MARKET_OPEN <= hour < MARKET_CLOSE:
print(json.dumps({
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "ask",
"permissionDecisionReason": f"{tool_name} called during market hours — confirm with a human.",
}
}))
sys.exit(0)
Save to a path inside your project, e.g. .claude/hooks/require-confirmation-trade-tools-market-hours.sh, then chmod +x it.
2. Wire it into .claude/settings.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "mcp__.*order.*|mcp__.*trade.*",
"hooks": [
{"type": "command", "command": "python3 .claude/hooks/require-confirmation-trade-tools-market-hours.py"}
]
}
]
}
}
Before you use this
A hook runs with your local shell's permissions — review the script above before adding it, the same way you'd review any script you didn't write yourself. See our guide on hook security risks for the specific CVEs this category of feature has already produced.
Related hooks