Claude Code Hooks vs MCP Servers: What to Automate First

A hook is a deterministic script wired to a lifecycle event — it runs the same way every time, with or without the model's cooperation, and a PreToolUse hook can block an action outright by exiting with status 2. An MCP server is a running process the model talks to mid-conversation to read or change state in something external — a database, a billing account, a GitHub repo. Neither replaces the other: hooks enforce what happens inside the session, MCP servers reach outside it. Last updated 2026-10-31 by Rakshit Yadav.

The two primitives, one paragraph each

Hooks are scripts registered in .claude/settings.json against lifecycle events — PreToolUse, PostToolUse, Notification, Stop, SessionEnd, and others. They run unconditionally, with no model judgment involved, which is what lets a PreToolUse hook actually block a tool call (exit code 2) instead of just asking nicely. A hook has no network dependency by default — it's a local script reading JSON off stdin, usually finishing in milliseconds.

MCP servers are the opposite shape: a running process, usually started with claude mcp add, that exposes tools (actions like "create a Stripe refund") and sometimes resources (read-only context like a live schema dump) over the Model Context Protocol. The model decides when to call them, mid-conversation, and the answer comes back from whatever system is actually running right now — not a snapshot written at setup time.

The short version: hooks answer "did this just happen, and should it be allowed to" — MCP servers answer "what's actually true out there right now, and can I act on it."

Decision table: 8 common solo-founder tasks

TaskReach forWhy
Auto-format a file on saveHookPostToolUse after Edit/Write — no external system involved, just the file that changed
Block a destructive shell command (rm -rf, force-push to main)HookNeeds to stop the action before it runs — only PreToolUse + exit 2 can do that
Check whether a migration matches the live Postgres/Supabase schemaMCPThe schema can drift after the last person touched schema.ts; only a live query is trustworthy
Stop a commit that touches .env or a secrets fileHookMust hold even if the model forgets or disagrees — deterministic, not advisory
Look up a customer's Stripe subscription status before answering a support ticketMCPNeeds the current account state, not a cached description of the Stripe API
Run the test suite automatically after any edit to src/HookFixed, repeatable action tied to a file-change event, no external data needed
Check if last night's CI run passed, or read a reviewer's PR commentMCPGitHub's state changes outside the session — a hook has nothing to poll against without one
Notify you (sound, Slack, desktop) when Claude is idle and waitingHookNotification/Stop events exist exactly for session-level signals like this

The pattern underneath: if the trigger is something that just happened inside this session, it's a hook. If the answer depends on a system that changes independently of the conversation, it's MCP.

When to use both together

The two compose rather than compete. A common solo-founder pairing: a Supabase MCP server gives the agent a live read on the actual schema and RLS policies before it writes a migration, while a PostToolUse hook on Write/Edit runs prettier and the type-checker on the migration file the moment it's saved — catching syntax and formatting problems a second before the agent moves on. Neither one does the other's job: the MCP call prevents a migration from being wrong against reality, the hook prevents it from being malformed as a file. Same logic applies to Stripe work — an MCP server answers "what does this customer's subscription actually look like right now," while a hook can block the agent from editing the webhook handler without also touching its matching test file.

A good rule of thumb: wire the hook first, since it's a local script with no setup cost beyond a JSON entry, then add the MCP server once a task genuinely needs to see or change something outside the repo.

Setup: hook vs MCP server

A hook needs nothing but a JSON entry under the hooks key of .claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          { "type": "command", "command": "jq -r '.tool_input.command' | grep -qE 'rm -rf /|git push.*--force.*main' && exit 2 || exit 0" }
        ]
      }
    ]
  }
}

An MCP server needs a running process and usually credentials, added once from the CLI:

claude mcp add supabase -- npx -y @supabase/mcp-server-supabase --project-ref=<ref>
claude mcp list     # confirm it's connected
claude mcp remove supabase   # pull it back out

For more hook configs across formatting, bash-safety, idle notification, and PR-guardrail categories, see 15 Claude Code Hooks Examples. For a ranked list of which MCP servers solo founders actually reach for — Stripe, Supabase, GitHub, Playwright, Sentry — see Best MCP Servers for Claude Code SaaS Founders.

Related pages

Frequently asked questions

  • Can a hook call an MCP server?
    No — a hook runs a shell command, not a model turn, so it can't make an MCP tool call itself. The usual pattern is the model calling an MCP server mid-conversation, with a hook separately enforcing something deterministic (formatting, a blocked command) around that same turn.
  • Which one should a solo founder set up first?
    Hooks, usually — they need no credentials or external account, just a JSON entry, and cover the highest-value early win: blocking destructive commands and auto-formatting edits. Add MCP servers once a specific task needs live external state, like checking a real Stripe subscription or live database schema.
  • Do MCP servers replace the need for hooks?
    No. An MCP server gives the model data or actions from outside the session; it doesn't run unconditionally or block anything. A hook is still the only mechanism that enforces a rule whether or not the model agrees to follow it.
  • Does adding more MCP servers slow down every Claude Code session?
    Each connected MCP server's tools are described to the model on every turn, so adding many at once does add context overhead. Run `claude mcp list` periodically and remove servers you're not actively using rather than leaving every server you've ever tried connected.

Agents that already know when to reach for each

AgenticKit's 34 subagents come with the hooks and skills that gate their own actions — wire your own MCP servers in alongside them for live external access.