MCP PostToolUse hooks: verify tool_response format for MCP tools #19

Closed
opened 2026-02-24 19:42:45 +00:00 by forgejo_admin · 0 comments
Contributor

Context

From PR #17 review (round 2, MEDIUM-1).

Problem

post-mcp-merge-rebase.sh checks tool_response.merged via jq, but MCP tool results may be returned as a JSON string (from json.dumps()) rather than a parsed object. If Claude Code doesn't parse MCP string responses into objects, .tool_response.merged would be null and the fast-forward silently doesn't happen.

Current behavior is fail-safe (no harm), but the hook would be a no-op.

Suggested Fix

  1. Test by running an actual MCP merge and inspecting the PostToolUse stdin
  2. If tool_response is a string, add fromjson in the jq pipeline
  3. Document the PostToolUse input schema for MCP tools as a convention note

Files

  • hooks/post-mcp-merge-rebase.sh
## Context From PR #17 review (round 2, MEDIUM-1). ## Problem `post-mcp-merge-rebase.sh` checks `tool_response.merged` via jq, but MCP tool results may be returned as a JSON string (from `json.dumps()`) rather than a parsed object. If Claude Code doesn't parse MCP string responses into objects, `.tool_response.merged` would be null and the fast-forward silently doesn't happen. Current behavior is fail-safe (no harm), but the hook would be a no-op. ## Suggested Fix 1. Test by running an actual MCP merge and inspecting the PostToolUse stdin 2. If tool_response is a string, add `fromjson` in the jq pipeline 3. Document the PostToolUse input schema for MCP tools as a convention note ## Files - `hooks/post-mcp-merge-rebase.sh`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ldraney/claude-custom#19
No description provided.