Hook matcher documentation doesn't clarify regex syntax — leads to silent failures with MCP tools

Resolved 💬 2 comments Opened Apr 7, 2026 by ttf3289 Closed Apr 9, 2026

The \matcher\ field in hook configuration is described as a "string pattern to match" with examples like \"Write"\ and \"Write|Edit"\. There is no indication that matchers are evaluated as regex patterns.

This becomes a practical problem when setting up hooks for MCP tools. A natural attempt like:

\\\json
"matcher": "mcp__Claude_in_Chrome"
\
\\

will silently fail to match \mcp__Claude_in_Chrome__navigate\, \mcp__Claude_in_Chrome__find\, etc. — because the matcher requires an exact string match unless regex syntax is used.

The correct pattern is:

\\\json
"matcher": "mcp__Claude_in_Chrome__.*"
\
\\

But there is nothing in the current documentation to indicate this.

Suggested fix:

In the hooks documentation, add explicit language that matchers are regex patterns, and add an MCP tool example:

\\\json
{
"hooks": {
"PreToolUse": [
{
"matcher": "mcp__your_server_name__.*",
"hooks": [{ "type": "command", "command": "your-command" }]
}
]
}
}
\
\\

A note that \|\ is regex OR and \.*\ matches any suffix would prevent this from being a recurring support question.

Impact: Silent hook failures — the hook is written correctly, JSON validates, but the tool calls never trigger it. No error is shown.

View original on GitHub ↗

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