Permission tool
Hello! I'm building my own workflows on top of Claude Code using this SDK. Some of these workflows require a human in the loop. Everything works Ok except for permission checks! I built an MCP server to handle permission checks. It pops up a prompt for a human to approve/deny. It works great, except the MCP tool call times out after 5 minutes. I can't always expect a human to respond within 5 minutes. It would be nice to either (A) configure the timeout for this particular tool (and possibly set it to infinite?), or (B) support permission handling another way, like via a new message type. I'd very much prefer the latter since it would support indefinite timelines and it seems like it would fit naturally into the conversation flow.
+1 this is pretty critical to building a production system
Yep, we should be able to configure the permission mCP timeout as well as hook timeouts (I'm looking at you, PreToolUse)
But now that it's 2026, I have low expectations of this being fixed. I have made my auto processes have a timeout for killing Claude code if we think a timeout is going to happen. Very annoying.
+1 i encountered the same problem.
+1 same problem in production
This has been resolved with the addition of the can_use_tool callback on ClaudeAgentOptions (added in v0.1.29+). This is an async callback that gives you full programmatic control over permission decisions without the MCP tool timeout limitation:
async def my_permission_handler(tool_name: str, input: dict, context: ToolPermissionContext) -> PermissionResult:
# Wait indefinitely for human approval - no 5-minute timeout
approved = await get_human_approval(tool_name, input)
if approved:
return PermissionResultAllow()
return PermissionResultDeny(reason="User denied")
options = ClaudeAgentOptions(
can_use_tool=my_permission_handler,
# ...
)
Additionally, PermissionRequest hook events provide another mechanism for permission handling with configurable timeouts.
Both approaches (A) and (B) from the original request are now addressed.
Generated by Claude Code