Combining MCP and Hooks
Let's build a workflow that checks analytics before removing code.
The Setup
- MCP: Connect
analytics-dbserver - Hook:
PreToolUseondelete_file
The Process
- User: "Remove the LegacyLogin component"
- Before deletion, Claude checks analytics: "Query analytics-db for 'LegacyLogin' usage in last 30 days"
- If count > 0: Claude aborts and reports findings
- If count == 0: Claude proceeds, post-hook runs build
This turns Claude from a text editor into a context-aware engineer!