SetDndModeTool

class SetDndModeTool(context: Context) : McpTool

Sets the Do Not Disturb interruption filter.

Calls android.app.NotificationManager.setInterruptionFilter. Requires DND policy access (isNotificationPolicyAccessGranted), a special access granted via Settings > Apps > Special access > Do Not Disturb access; without it the tool returns an error. Idempotent (setting the same mode twice has the same effect).

Android 15+ (API 35): for apps targeting API 35, setInterruptionFilter no longer changes the global DND state directly — it activates/deactivates the calling app's implicit AutomaticZenRule. The system merges that rule with the user's own settings and other apps' rules, so the resulting global filter may differ from the one requested (e.g. requesting off cannot override DND the user turned on). The tool therefore reads back NotificationManager.getCurrentInterruptionFilter after the call and reports it as actual_mode; applied is true only when it matches the requested mode, and note explains any mismatch.

Output keys: success, mode (requested), actual_mode (off/priority/alarms/none/ unknown), applied, note (present only when the actual mode differs).

Constructors

Link copied to clipboard
constructor(context: Context)

Properties

Link copied to clipboard
open override val annotations: ToolAnnotations
Link copied to clipboard
open override val description: String
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val outputSchema: Map<String, Any>
Link copied to clipboard
open override val parameters: List<ToolParameter>

Functions

Link copied to clipboard
open suspend override fun execute(params: Map<String, Any>): ToolResult