ReadCalendarTool

class ReadCalendarTool(context: Context) : McpTool

Reads calendar events in a date range via ContentResolver on CalendarContract.Instances, so recurring events are expanded into their individual occurrences and multi-day events that began before start_date but are still running are included. An instance is returned when it overlaps the window [start_date 00:00, end_date + 1 day 00:00). (The provider drops a soft-deleted event's instance rows itself, so no DELETED filter is needed — Instances doesn't expose that column.) Requires READ_CALENDAR.

Timed events are windowed and formatted in the device timezone. All-day events are stored by the provider at UTC-midnight boundaries, so they are windowed against the same calendar dates in UTC and their start/end are formatted in UTC — an all-day event on 2024-05-01 reads back as 2024-05-01 00:00 – 2024-05-02 00:00 regardless of the device's offset.

Output: events (list of {id, title, start, end, location, description, all_day} with times formatted yyyy-MM-dd HH:mm; id is the underlying event id, so all occurrences of a recurring event share it) and count, sorted by instance start and capped at limit (1–100, default 10). start_date/end_date are strict yyyy-MM-dd.

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