Initial commit
This commit is contained in:
23
hooks/scripts/webfetch_to_tavily_extract.py
Executable file
23
hooks/scripts/webfetch_to_tavily_extract.py
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
PreToolUse hook: intercept WebFetch → suggest using tavily-extract instead
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
try:
|
||||
data = json.load(sys.stdin)
|
||||
url = data["tool_input"]["url"]
|
||||
except (KeyError, json.JSONDecodeError) as err:
|
||||
print(f"hook-error: {err}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
print(json.dumps({
|
||||
"systemMessage": "WebFetch detected. AI is directed to use Tavily extract instead.",
|
||||
"hookSpecificOutput": {
|
||||
"hookEventName": "PreToolUse",
|
||||
"permissionDecision": "deny",
|
||||
"permissionDecisionReason": f"Please use mcp__tavily__tavily-extract with urls: ['{url}'] and extract_depth: 'advanced'"
|
||||
}
|
||||
}, separators=(',', ':')))
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user