Skip to content

Claude Code Integration

Claude Code fires PostToolUse hooks after every tool call — including native host tools that never go through an MCP server. Wiring up agent-receipts-hook as a PostToolUse hook ensures those calls appear in the daemon receipt chain alongside MCP tool calls captured by mcp-proxy.

Add the following to your ~/.claude/settings.json (user-global, all projects) or to .claude/settings.json in a specific project:

{
"hooks": {
"PostToolUse": [
{
"matcher": "",
"hooks": [{ "type": "command", "command": "agent-receipts-hook" }]
}
]
}
}

The empty matcher string covers all tools. Claude Code spawns agent-receipts-hook with a JSON frame on stdin after each tool call completes.

After running any Claude Code tool (e.g. a Bash command), check the dashboard — receipts with channel: claude-code should appear alongside any MCP receipts from mcp-proxy.

Claude Code serialises each PostToolUse event as a JSON object on stdin:

{
"hook_event_name": "PostToolUse",
"session_id": "<current session ID>",
"tool_name": "Bash",
"tool_input": { "command": "go test ./..." },
"tool_response": { "output": "PASS", "exit_code": 0 }
}

agent-receipts-hook maps this to:

Receipt fieldSource
channelFixed: "claude-code"
tool.nametool_name from stdin
tool.serverEmpty (native tools have no server)
inputtool_input as raw JSON
outputtool_response as raw JSON
decisionFixed: "allowed" (PostToolUse fires after the tool ran)
session_idsession_id from stdin

The empty matcher captures mcp__* tools too, which mcp-proxy already covers. This produces a second receipt per MCP call — one at channel: "mcp" from the proxy, one at channel: "claude-code" from the hook. They are distinguishable by their channel field. If you want to exclude MCP tools from the hook, add a non-empty matcher or restrict the hook to specific tool names. See the overview for more detail.

Claude Code passes the same session_id across all tool calls in a session. Both the hook and mcp-proxy forward this ID to the daemon, so all receipts from a given session are grouped together regardless of which channel they came from.

FlagDescription
--formatForce a specific input format. Defaults to auto-detection via hook_event_name in the stdin payload or the CLAUDE_SESSION_ID environment variable. Currently supported: claude-code.

The --format flag is intended for testing and future runtime support. In normal Claude Code usage, auto-detection is sufficient.