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