Hooklaw
Webhook orchestrator with AI agents and MCP tools. BYOK, self-hosted.
Ask AI about Hooklaw
Powered by Claude Β· Grounded in docs
I know everything about Hooklaw. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
HookLaw
Event-driven AI agents with native MCP tools.
Webhooks & RSS feeds in. MCP tools out. AI agent in the middle.
Stripe webhook βββ Recipe βββ QuickBooks MCP (create invoice)
GitHub webhook βββ Recipe βββ Slack MCP (post message)
HN RSS feed βββ Recipe βββ Slack MCP (daily digest)
Any event βββ Recipe βββ Any MCP server
HookLaw connects any event source (webhooks, RSS/Atom feeds) to any MCP server through AI agents. Define recipes in YAML, bring your own API keys, self-host it.
Why HookLaw
Other platforms treat webhooks as just another input channel for their AI assistant. HookLaw is event-first: every event source gets its own AI agent and MCP tool connections.
- Proactive, not just reactive β RSS feeds let your agents monitor the world and act on new information automatically
- Multi-agent chains β recipes trigger other recipes on success/error with depth tracking
- Human-in-the-loop β agents pause for approval before taking action
- Agent memory β conversation context persists across executions
- Conditional routing β AI evaluates which recipe handles each event
- Full observability β traces of every LLM call, tool call, and result
- Config-as-code β one YAML file defines everything, versionable in git
- Self-hosted β your data, your keys, your infrastructure
- Interactive setup β built-in dashboard with guided onboarding wizard
MCP done right
| HookLaw | Others | |
|---|---|---|
| MCP client | Native, via @modelcontextprotocol/sdk | Shell out to CLI tools |
| Connection | Persistent pool, reusable | Cold-start per call |
| Latency | Sub-second tool calls | ~2.4s overhead per invocation |
| Transport | stdio + SSE | stdio only |
| Management | Dashboard with health checks & install | Manual config |
Event Sources
| Source | How it works |
|---|---|
| Webhooks | POST /h/:slug β receive events from any service |
| RSS/Atom Feeds | Poll feeds on interval, deduplicate via content hash |
Recipes
A recipe connects an event source to MCP tools through an AI agent. Multiple recipes can share the same slug β one Stripe payment triggers invoice creation AND sends a notification.
βββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββ
β Sources β β HookLaw β β MCP Servers β
β β β β β β
β Stripe βββΌβββββΆβ Recipe: payment-to-invoice ββββββΆβ Stripe MCP β
β webhook β β AI agent orchestrates the flow ββββββΆβ QuickBooks β
β β β β β β
β GitHub βββΌβββββΆβ Recipe: pr-review ββββββΆβ GitHub MCP β
β webhook β β AI agent reviews code β β β
β β β β β β
β HN RSS βββΌβββββΆβ Recipe: hn-digest ββββββΆβ Slack MCP β
β feed β β AI agent summarizes & posts β β β
β β β β β β
β Any src βββΌβββββΆβ Recipe: your-automation ββββββΆβ Any MCP β
βββββββββββββββ βββββββββββββββββββββββββββββββββββββββββ ββββββββββββββββ
Quick Start
npx hooklaw start
No config file? HookLaw launches an interactive setup wizard in your browser β pick a provider, choose an event source (webhook or RSS), select integrations, and you're running.
Or install globally:
npm install -g hooklaw
hooklaw start
Dashboard
HookLaw includes a built-in web dashboard for managing everything:
- Recipes β view, edit, and create new automation recipes
- Executions β real-time execution logs with payload and agent output
- MCP Servers β health checks, tool discovery, install packages, add new servers
- Feeds β monitor active RSS/Atom feed pollers
- Config β visual YAML config viewer
Configuration
server:
port: 3007
providers:
anthropic:
api_key: ${ANTHROPIC_API_KEY}
# Shared MCP servers β define once, use in any recipe
mcp_servers:
stripe:
transport: stdio
command: npx
args: ["-y", "@stripe/agent-toolkit", "--tools=all"]
env:
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
slack:
transport: stdio
command: npx
args: ["-y", "@anthropic/mcp-server-slack"]
# RSS/Atom feed sources
feeds:
hn-top:
url: https://hnrss.org/newest?points=100
slug: hn-digest
refresh: 300000 # poll every 5 minutes
skip_initial: true # don't process existing items on first run
enabled: true
# Recipes connect events β AI agents β MCP tools
recipes:
payment-to-invoice:
description: "Auto-create invoice on Stripe payment"
slug: stripe-payment # POST /h/stripe-payment
mode: async
agent:
provider: anthropic
model: claude-sonnet-4-6
instructions: |
When a Stripe payment succeeds, extract customer details
and create an invoice in QuickBooks.
tools: [stripe, quickbooks] # MCP servers this recipe uses
hn-digest:
description: "Summarize top HN stories and post to Slack"
slug: hn-digest # matches feed slug above
mode: async
agent:
provider: anthropic
model: claude-sonnet-4-6
instructions: |
Summarize this Hacker News story in 2-3 sentences.
Post to #tech-news on Slack with the title, link, and summary.
tools: [slack]
logs:
retention_days: 30
Environment variables (${VAR}) are substituted from .env or the environment.
How It Works
- An event arrives β webhook
POST /h/stripe-paymentor a new RSS item - HookLaw finds all recipes matching the slug
- Each recipe runs its AI agent with the event payload
- Agents use MCP tools to take action (create invoices, send messages, etc.)
- Everything is logged with full execution history
Sync mode β waits for the agent and returns the response in the HTTP reply.
Async mode β returns 200 Accepted immediately, processes in background.
API
| Method | Path | Description |
|---|---|---|
POST | /h/:slug | Receive webhook |
GET | /health | Health check |
GET | /api/recipes | List all recipes |
POST | /api/recipes | Create a recipe |
PATCH | /api/recipes/:id | Update a recipe |
GET | /api/executions | All executions (filterable) |
GET | /api/executions/:id/traces | Agent reasoning traces |
GET | /api/executions/:id/chain | Child executions in a chain |
POST | /api/executions/:id/approve | Approve/reject execution |
GET | /api/approvals | Pending approval queue |
GET | /api/recipes/:id/memory | Agent memory for a recipe |
DELETE | /api/recipes/:id/memory | Clear agent memory |
GET | /api/stats | Execution statistics |
GET | /api/mcp-servers | List MCP servers |
POST | /api/mcp-servers | Add MCP server |
GET | /api/mcp-servers/health | Check all MCP health |
GET | /api/feeds | List active feed pollers |
GET | /api/config | Redacted config |
Providers
Bring your own API keys. Supports:
| Provider | Config key | Notes |
|---|---|---|
| Anthropic | anthropic | Claude models |
| OpenAI | openai | GPT models |
| OpenRouter | openrouter | Multi-model gateway |
| Ollama | ollama | Local models, set base_url |
MCP Servers
HookLaw works with any MCP server. Popular options:
| Server | Transport | Package |
|---|---|---|
| Stripe | stdio | @stripe/agent-toolkit |
| GitHub | stdio | @modelcontextprotocol/server-github |
| Slack | stdio | @anthropic/mcp-server-slack |
| Linear | stdio | mcp-linear |
| Notion | stdio | @anthropic/mcp-server-notion |
| PostgreSQL | stdio | @modelcontextprotocol/server-postgres |
| Filesystem | stdio | @modelcontextprotocol/server-filesystem |
| Any SSE server | sse | Your URL |
Architecture
hooklaw.config.yaml
β
βΌ
ββββββββββββββββ ββββββββββββ βββββββββββββ ββββββββββββ
β HTTP Server ββββββΆβ Router ββββββΆβ Agent ββββββΆβ MCP Pool β
β /h/:slug β β Recipe β β Tool Loopβ β stdio β
β /api/* β β Matcher β β (max 10) β β sse β
β /dashboard β β β β β β β
ββββββββββββββββ ββββββββββββ βββββββββββββ ββββββββββββ
β² β β
β βΌ βΌ
ββββββββββββββββ ββββββββββββ ββββββββββββ
β RSS/Atom β β SQLite β β External β
β Feed Poller β β (WAL) β β MCP Svrs β
ββββββββββββββββ ββββββββββββ ββββββββββββ
Stack: TypeScript, Node.js, SQLite (better-sqlite3), Zod, Pino
Development
git clone https://github.com/lucianfialho/hooklaw.git
cd hooklaw
pnpm install
pnpm test # vitest
pnpm run typecheck # strict TypeScript
pnpm run dev # start with tsx (hot reload)
Project Structure
packages/
βββ core/ # Core engine
β βββ src/
β βββ types.ts # Zod schemas (recipes, MCP servers, providers, feeds)
β βββ config.ts # YAML loader with ${ENV_VAR} substitution
β βββ db.ts # SQLite (executions CRUD)
β βββ mcp.ts # MCP client pool (stdio + SSE, persistent connections)
β βββ agent.ts # Agentic tool loop (max 10 iterations)
β βββ feeds.ts # RSS/Atom feed poller with dedup
β βββ queue.ts # Per-recipe async queue with concurrency control
β βββ router.ts # Recipe matcher + orchestrator
β βββ server.ts # HTTP server (webhook receiver + REST API)
β βββ setup.ts # Interactive setup wizard server
β βββ index.ts # Bootstrap + wiring
β βββ providers/
β βββ base.ts # LLM provider interface
β βββ anthropic.ts # Anthropic provider
β βββ openai.ts # OpenAI/OpenRouter/Ollama provider
β βββ index.ts # Provider factory + cache
βββ dashboard/ # React SPA (Vite + React Router)
βββ cli/ # CLI (hooklaw start, hooklaw init)
βββ hooklaw/ # Published npm package (re-exports core + cli)
License
MIT β self-host it, modify it, do whatever you want.
