[FEATURE] Allow hooks to invoke MCP tool calls (not just shell commands)

Resolved 💬 3 comments Opened Mar 13, 2026 by santunioni Closed Apr 23, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Hooks (PreToolUse, PostToolUse, etc.) currently only support "type": "command" (shell commands). This makes it impossible to trigger MCP tool calls in response to events, which limits automation of MCP-based workflows.

When using an MCP server that manages stateful resources (e.g., browser tabs, connections), there is no deterministic way to automatically clean up those resources after Claude finishes a task. The cleanup tool exists and works fine when Claude calls it explicitly — but there is no hook mechanism to ensure it runs after specific tool calls.

Proposed Solution

Add a new hook action type "type": "mcp_tool" with fields:

  • server: the MCP server name
  • tool: the tool to invoke
  • arguments (optional): static arguments to pass

Example configuration:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "mcp__playwright__browser_snapshot",
        "hooks": [
          {
            "type": "mcp_tool",
            "server": "playwright",
            "tool": "browser_close"
          }
        ]
      }
    ]
  }
}

This would make hooks composable with the full MCP ecosystem, not just shell commands.

Alternative Solutions

  • Add an instruction to CLAUDE.md asking Claude to always call the cleanup tool after use — but this relies on model compliance and is not deterministic.
  • Ask Claude explicitly every time — works but requires manual intervention on every task.

Priority

Medium - Would be very helpful

Feature Category

MCP server integration

Use Case Example

When using the Playwright MCP server to browse a URL and take a snapshot, the browser tab remains open after the task is done. There is no way to automatically close it via a PostToolUse hook because hooks only support shell commands, not MCP tool calls. A "type": "mcp_tool" hook action would allow automatically invoking browser_close after browser_snapshot completes, keeping the browser clean without relying on Claude remembering to do it.

Additional Context

This pattern would be broadly useful beyond Playwright — any MCP server that manages stateful or expensive resources (database connections, file handles, external sessions) would benefit from being able to register cleanup actions as hooks.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗