# Hooks vs MCP for Claude Code and Codex: when to use each

Source: https://www.ac-bridge.com/guides/hooks-vs-mcp

Last updated 4 December 2026

**The short answer**

Use **agent hooks** when an action must run deterministically on a lifecycle event such as `Stop`, `Notification` or `PermissionRequest` with zero model tokens and no reliance on prompts. Use **MCP tools** when the agent itself should inspect live state, reason over options or execute an ad-hoc action you ask for in chat.

## Hooks vs MCP decision table

Both hooks and the Model Context Protocol connect Claude Code and Codex to your machine, but they sit on opposite sides of the control loop: the runtime drives hooks, while the model drives MCP.

| Dimension | Agent hooks | MCP tools |
| --- | --- | --- |
| Who triggers it | The CLI runtime, automatically on a named lifecycle event. | The model, when a prompt or plan calls for a tool. |
| Token overhead | Zero model tokens; no tool schemas sit in the prompt. | Consumes context for tool definitions and tool call results. |
| Reliability | Deterministic: runs every time the event fires, even if the model forgets. | Model-guided: flexible for open-ended requests, not guaranteed on every turn. |
| Best fit | Notifications, status lights, formatters, audit logs and policy gates. | Reading device state, multi-device scenes and plain-English task steps. |
| Where configured | `settings.json` (Claude Code) or `hooks.json` / `config.toml` (Codex). | Plugin `.mcp.json` / Claude config or `[mcp_servers]` in `config.toml`. |

## When deterministic hooks are the right tool

Never ask an LLM prompt to remember a side effect that must happen every single time. Lifecycle hooks fire inside the host runtime whether the session is two turns deep or near compaction.

### Always-on awareness and alerts

Events like `Stop`, `Notification` and `PermissionRequest` fire automatically when the agent finishes a turn or waits for approval, with zero model tokens spent. See the [Claude Code hooks reference](https://www.ac-bridge.com/guides/claude-code-hooks) and the [Codex hooks and config.toml reference](https://www.ac-bridge.com/guides/codex-hooks) for event schemas.

### Guardrails, formatting and logging

`PreToolUse` and `PostToolUse` hooks enforce deterministic rules, run formatters after file writes or append shell audit trails without hoping the model follows a system-prompt reminder.

## When model-invoked MCP tools win

Hooks cannot read your intent mid-conversation or compose a multi-step hardware command from a plain-English request. That is what a local MCP server provides.

### Reading state before acting

An MCP server lets the model inspect available devices, check whether a plug or light is already on and read supported capabilities before deciding which action to run.

### Task-specific multi-device actions

When you ask an agent to flash a kitchen light once a deploy succeeds, switch off a desk fan after a build finishes or trigger a named scene during deep work, the model invokes MCP tools at the exact step in the task where it makes sense.

## Combining hooks and MCP cleanly

Hooks and MCP are complementary layers, not competing architectures. A clean local setup splits the two responsibilities so neither layer fights the other:

1. **Let hooks own ambient session state.** Working, needs permission, error and finished states come straight from runtime hooks with zero model tokens.
2. **Let MCP own explicit chat requests.** When you ask in chat to dim lights, flip a plug or run a scene at the end of a pipeline, the agent calls MCP tools on demand.
3. **Keep safety enforcement server-side.** Never rely on prompts alone to block risky hardware; enforce hard refusals for security devices inside the local hub or server itself.

## Questions people ask

### Do agent hooks use LLM context tokens?

No. Command hooks run outside the model loop with zero model tokens unless a hook intentionally prints text back into context (such as a `SessionStart` reminder). Quiet async notifiers add zero token cost.

### Can a hook call an MCP tool directly?

Standard command hooks communicate through stdin, stdout, stderr and exit codes rather than invoking an MCP tool through the model. If a deterministic hook needs to drive hardware, have the hook script call your local hub or device API directly, and reserve MCP tools for model-driven actions in chat.

### Should notifications use hooks or MCP?

Always use lifecycle hooks for notifications and status indicators so you are alerted reliably when a turn ends or pauses for approval. Use MCP only when you want the agent to control hardware as part of a task you asked for.

### Can Claude Code and Codex share one local MCP server?

Yes. Both hosts speak standard stdio MCP, so one local server binary can be wired into Claude Code via a plugin `.mcp.json` and into Codex via `[mcp_servers]` in `~/.codex/config.toml`.

## Or let a light show it

You do not have to maintain separate hook scripts and a custom local MCP server yourself. One desktop app wires both halves cleanly for Claude Code and Codex on your home network.

**What it does**

AC Bridge uses deterministic lifecycle hooks for free ambient status lights across your smart bulbs and plugs, and adds a local MCP server on Pro (four device tools: `list_devices`, `get_device`, `set_device` and `run_scene`) so Claude Code and Codex can also control devices in plain English.

**What it follows**

Hooks drive 29 agent states on Claude Code (needs permission follows Claude Code's `permission_prompt` notification) and 19 states on Codex (including `PermissionRequest` and `Stop` hooks). On Pro, ticking "Make agent aware of devices in chat" exposes the local MCP tools per profile while keeping locks, garage doors, valves and cameras refused for agents. See [how the Claude Code status light works](https://www.ac-bridge.com/claude-code-status-light) and [Direct LAN vs Home Assistant](https://www.ac-bridge.com/guides/direct-lan-vs-home-assistant).

**What it costs**

AC Bridge is free to use: one Claude Code profile and one Codex profile, each lighting one device on one repo at a time, with as many devices as you like switched on or off from the app. Pro is GBP 12.99 once, not a subscription: as many profiles as you want for each agent, several devices in a profile, profiles on every repo at once, and your agent can control your devices. It works with the Claude Code or Codex you already run, on Windows, macOS or Linux, with no model API key to buy.

**What it collects**

LAN devices are driven straight from your machine and their keys never leave it; your account, settings, device list, usage counts and session states sync through our servers. Your prompts, code and session transcripts are never collected. [Privacy policy](https://www.ac-bridge.com/privacy#what-we-collect).

**Try it on your own lights**

Turn the lights you already own into a status light for Claude Code and Codex, and see from across the room when a session needs you. [Get started free](https://www.ac-bridge.com/register), or read the [setup docs](https://www.ac-bridge.com/docs) first. On Pro, ask Claude Code or Codex in plain English to switch, dim or recolour your lights, plugs and more. [How MCP device control works](https://www.ac-bridge.com/mcp)
