PostToolUse hooks with additionalContext not surfacing for MCP tool calls
Status Closed — not planned
Maintainer reply ✓ Yes — localden
Workaround ✓ Mentioned in thread ↓
Activity 11 comments · opened Feb 10, 2026 · closed Jun 1, 2026
💡 Likely answer: A maintainer (localden, collaborator)
responded on this thread — see the highlighted reply below.
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:
additionalContextis 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.jsonand 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_containermirror-bootstrap-prompt.sh→mcp__*__get_next_taskstatus-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
11 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Additional Context — Related Issues
After further investigation, this appears to be part of a broader pattern:
additionalContext,systemMessage,modifyResult, and plain stdout all fail to surface for PostToolUse hooks on any tool type (not just MCP).additionalContextto Claude.Key Distinction
Our original report focused on MCP tools specifically, but #18427 demonstrates that PostToolUse
additionalContextdoesn't work for any tool type. The MCP-specific aspect compounds this because:updatedInputworkaround from #18427 (appending context to Bash commands) cannot apply to MCP tool calls — there's no shell command to modifyadditionalContextinjection path is brokenImpact
This blocks an entire category of plugin automation: hooks that need to advise the agent based on tool results (e.g., prompting mirror task creation after MCP task creation, suggesting next actions after status transitions). The only working hook-to-agent communication path for MCP tools is the blocking pattern (exit 2), which is inappropriate for advisory prompts.
Related data point: we confirmed PostToolUse
additionalContextworks for all native tools (Grep, Glob, Write, Edit) on v2.1.45 using non-plugin hooks in~/.claude/settings.json. This suggests the issue in this report is specific to MCP tool calls (and/or plugin-defined hooks), not a general PostToolUse pipeline failure.Our hooks use
{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"..."}}with exit 0.Additional note:
tool_responsein PostToolUse stdin is a JSON object (e.g.,{"mode":"files_with_matches","filenames":[],"numFiles":0}for Grep), not the display string — relevant for hook authors writing pattern matchers.Don't ignore this bug, please please fix this! PostToolUse using additionalContext does not work when triggered by an MCP tool call.
This issue remains critical for our workflow. Empirically confirmed on v2.1.81 (Mar 15 + Mar 21, 2026):
additionalContextviahookSpecificOutputwrapper works correctly on PostToolUse.We have 6 PostToolUse hooks affected. The workaround (
exit 2+ stderr, ordecision: "block"+reason) works but loses the non-blocking advisory injection pattern.This is the most impactful open hook infrastructure bug for anyone with MCP-heavy setups. Would appreciate any update on whether this is being tracked internally.
Still affecting our production setup on v2.1.107 (macOS, Teams plan, 7 MCP servers via stdio + HTTP). We have 6 PostToolUse hooks that match MCP tools — all silently lose their
additionalContextinjection. Current workaround: using exit-2-stderr pattern for critical hooks on MCP tools, but this only works for PreToolUse deny (not PostToolUse context injection).This also interacts with #42702 (stdin contention when multiple PreToolUse hooks match same tool) — both bugs reduce the reliability of the hook pipeline for MCP integrations.
Would be helpful to know if this is on the roadmap or if there's a known architectural reason MCP tools handle hook output differently than built-in tools.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
We investigated this and added a regression test confirming
PostToolUseadditionalContextreaches the API for MCP tools the same as native tools. The hookResults attachment loop runs after the MCP/native branch, so there is no MCP-specific drop. If you still see additionalContext missing on a current version, please open a new issue withclaude --version, your hook config, and--debugoutput.Confirming fixed for our setup: tested today on v2.1.174 (macOS,
settings.json-registered PostToolUse hooks) across MCP stdio and HTTP transports plus a native-tool control — every arm'sadditionalContextreached the model (transcript shows thehook_additional_contextattachment for each MCP call; model echoed the injected sentinels). Not retested: the original Windows/plugin-registered-hook path and SSE.Also correcting my Apr 14 comment: "still affecting v2.1.107" was not based on a fresh runtime test — our own Mar 28 retest had already found this working on v2.1.85. So for our setup: failing through v2.1.81, working from v2.1.85 onward.
Thanks @localden for the regression test. If you're still hitting this, re-test on a current build before keeping an exit-2/stderr workaround; if it persists, open a new issue with
claude --version, hook config, and--debugoutput.This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.