Description
PostToolUse hooks that output JSON with additionalContext and exit 0 produce no visible output when triggered by MCP tool calls. The hook scripts work correctly when tested manually (piping JSON stdin and checking stdout), but no additionalContext is injected into the conversation after MCP tool execution.
Reproduction
- Register a PostToolUse hook matching an MCP tool:
{
"PostToolUse": [
{
"matcher": "mcp__mcp-task-orchestrator__manage_container",
"hooks": [
{
"type": "command",
"command": "bash \"$CLAUDE_PROJECT_DIR\"/scripts/test-hook.sh",
"timeout": 5
}
]
}
]
}
- Hook script outputs valid JSON:
{
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": "New MCP task created: [abcd1234] My Task. Create a CC mirror task..."
}
}
Script exits with code 0.
-
Call the MCP tool (e.g., create a task via manage_container)
-
Expected: additionalContext is injected into the conversation as context for the model
-
Actual: No hook output appears. Tool result shows only the MCP server response.
Verification
- Script tested manually with
echo '<json>' | bash script.sh — produces correct JSON output, exits 0
- Tested with hooks registered both via plugin
session-hooks.json and directly in .claude/settings.local.json
- Tested across session restarts (hooks load fresh at startup)
- TaskCompleted hooks DO work using stderr + exit 2 pattern on the same MCP tool results — confirming hook matching/registration is functional
Affected hook types
All PostToolUse hooks matching MCP tools with additionalContext output:
create-mirror-prompt.sh → mcp__*__manage_container
mirror-bootstrap-prompt.sh → mcp__*__get_next_task
status-sync.sh → mcp__*__request_transition
Environment
- Claude Code CLI (latest)
- Windows (MSYS_NT / Git Bash)
- MCP server running via Docker (stdio transport)
- Plugin hooks registered via
.claude-plugin/plugin.json → session-hooks.json
Description
PostToolUse hooks that output JSON with
additionalContextand exit 0 produce no visible output when triggered by MCP tool calls. The hook scripts work correctly when tested manually (piping JSON stdin and checking stdout), but noadditionalContextis injected into the conversation after MCP tool execution.Reproduction
{ "PostToolUse": [ { "matcher": "mcp__mcp-task-orchestrator__manage_container", "hooks": [ { "type": "command", "command": "bash \"$CLAUDE_PROJECT_DIR\"/scripts/test-hook.sh", "timeout": 5 } ] } ] }{ "hookSpecificOutput": { "hookEventName": "PostToolUse", "additionalContext": "New MCP task created: [abcd1234] My Task. Create a CC mirror task..." } }Script exits with code 0.
Call the MCP tool (e.g., create a task via
manage_container)Expected:
additionalContextis injected into the conversation as context for the modelActual: No hook output appears. Tool result shows only the MCP server response.
Verification
echo '<json>' | bash script.sh— produces correct JSON output, exits 0session-hooks.jsonand directly in.claude/settings.local.jsonAffected hook types
All PostToolUse hooks matching MCP tools with
additionalContextoutput:create-mirror-prompt.sh→mcp__*__manage_containermirror-bootstrap-prompt.sh→mcp__*__get_next_taskstatus-sync.sh→mcp__*__request_transitionEnvironment
.claude-plugin/plugin.json→session-hooks.json