Skip to content

HookConfigMcpTool

Base classes

Name Children Inherits
ClaudeCodeBaseModel
clawd_code_sdk.models.base
Base model for all Claude Code Pydantic models.

⋔ Inheritance diagram

graph TD
  1992988369["settings.HookConfigMcpTool"]
  2604142835["base.ClaudeCodeBaseModel"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  2604142835 --> 1992988369
  3879467795 --> 2604142835
  2751680898 --> 3879467795

🛈 DocStrings

Bases: ClaudeCodeBaseModel

MCP tool hook. Call a tool on an already-connected MCP server. See https://code.claude.com/docs/en/hooks#mcp-tool-hook-fields.

Source code in src/clawd_code_sdk/models/settings.py
class HookConfigMcpTool(ClaudeCodeBaseModel):
    """MCP tool hook. Call a tool on an already-connected MCP server. See https://code.claude.com/docs/en/hooks#mcp-tool-hook-fields."""

    model_config = ConfigDict(
        extra="forbid",
    )
    type: Literal["mcp_tool"] = "mcp_tool"
    """
    Hook type
    """
    server: str = Field(..., min_length=1)
    """
    Name of a configured MCP server (must already be connected)
    """
    tool: str = Field(..., min_length=1)
    """
    Name of the tool to call on that server
    """
    input: dict[str, Any] | None = None
    """
    Arguments passed to the tool. String values support ${path} substitution from hook JSON input (e.g., ${tool_input.file_path}, ${cwd})
    """
    timeout: float | None = Field(None, gt=0.0)
    """
    Optional timeout in seconds (default: 600; lowered to 30 on UserPromptSubmit and 10 on MessageDisplay)
    """
    on_failure: Literal["continue", "block"] | None = Field(None, alias="onFailure")
    """
    Whether the action that triggered the hook goes ahead when the hook fails: the server isn't connected, the tool returns an error, it times out, or the output is invalid. "block" does what exit code 2 does on that event, and denies the request on PermissionRequest. No effect on Stop, SubagentStop, TaskCompleted, and TeammateIdle hooks. Requires Claude Code v2.1.328 or later. See https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails
    """
    if_: str | None = Field(None, alias="if")
    """
    Optional permission-rule-syntax filter. Evaluated only on tool-related events (PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied); on other events a hook with `if` set never runs. See https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers
    """
    status_message: str | None = Field(None, alias="statusMessage")
    """
    Custom spinner message displayed while the hook runs
    """

if_ class-attribute instance-attribute

if_: str | None = Field(None, alias='if')

Optional permission-rule-syntax filter. Evaluated only on tool-related events (PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, PermissionDenied); on other events a hook with if set never runs. See https://code.claude.com/docs/en/hooks-guide#filter-hooks-with-matchers

input class-attribute instance-attribute

input: dict[str, Any] | None = None

Arguments passed to the tool. String values support ${path} substitution from hook JSON input (e.g., ${tool_input.file_path}, ${cwd})

on_failure class-attribute instance-attribute

on_failure: Literal['continue', 'block'] | None = Field(None, alias='onFailure')

Whether the action that triggered the hook goes ahead when the hook fails: the server isn't connected, the tool returns an error, it times out, or the output is invalid. "block" does what exit code 2 does on that event, and denies the request on PermissionRequest. No effect on Stop, SubagentStop, TaskCompleted, and TeammateIdle hooks. Requires Claude Code v2.1.328 or later. See https://code.claude.com/docs/en/hooks#block-the-action-when-a-hook-fails

server class-attribute instance-attribute

server: str = Field(..., min_length=1)

Name of a configured MCP server (must already be connected)

status_message class-attribute instance-attribute

status_message: str | None = Field(None, alias='statusMessage')

Custom spinner message displayed while the hook runs

timeout class-attribute instance-attribute

timeout: float | None = Field(None, gt=0.0)

Optional timeout in seconds (default: 600; lowered to 30 on UserPromptSubmit and 10 on MessageDisplay)

tool class-attribute instance-attribute

tool: str = Field(..., min_length=1)

Name of the tool to call on that server

type class-attribute instance-attribute

type: Literal['mcp_tool'] = 'mcp_tool'

Hook type

:fa-brands-github: Show source on GitHub