You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add Tool Permission Callbacks section to README
Add documentation for the can_use_tool callback mechanism that allows
programmatic control over which tools Claude can use at runtime. This
addresses issue #137 by making the feature more discoverable.
Includes:
- Basic example showing allow/deny patterns
- Example of modifying tool inputs before execution
- Comparison table: can_use_tool vs PreToolUse hooks
- Reference to the comprehensive example file
Copy file name to clipboardExpand all lines: README.md
+94Lines changed: 94 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -233,6 +233,100 @@ async with ClaudeSDKClient(options=options) as client:
233
233
print(msg)
234
234
```
235
235
236
+
### Tool Permission Callbacks
237
+
238
+
A **tool permission callback** (`can_use_tool`) lets you programmatically control which tools Claude can use at runtime. Unlike hooks which run after permission is granted, `can_use_tool` intercepts tool requests _before_ execution, allowing you to:
239
+
240
+
- Allow or deny specific tools based on their inputs
241
+
- Modify tool inputs before execution (e.g., redirect file paths)
242
+
- Implement custom security policies
243
+
- Log tool usage for auditing
244
+
245
+
**Important:** Without a `can_use_tool` callback, the SDK assumes "Denied" by default for operations outside the allowed working directory.
0 commit comments