Skip to main content

Module 08: Permissions

Handle permission requests from agents on the client side.

What You’ll Learn

  • Registering a requestPermissionHandler
  • PermissionOption and PermissionOptionKind types
  • Permission outcomes: selected vs cancelled

The Code

When an agent wants to perform a sensitive operation (like writing a file or running a command), it can ask the client for permission first. The client registers a requestPermissionHandler that receives the request details and a list of options (allow once, allow always, reject). Your handler decides which option to select — typically by showing a dialog to the user:

Permission Option Kinds

The agent sends a RequestPermissionRequest containing the tool call details and a list of options. The client presents choices to the user and returns the selected option ID. This completes the bidirectional request flow (with Module 07 for files).

Source Code

View on GitHub

Running the Example

Next Module

Module 09: Session Resume — load and resume existing sessions.