CalendarTool lets your agent read, create, and delete Google Calendar events. It can also find open time slots and add guests to existing events — useful for scheduling assistants and booking workflows.
Installation
Install the Google dependencies:google-api-python-client and the related auth libraries.
Authentication
CalendarTool requires a Google OAuth2Credentials object with access to the Google Calendar API. You are responsible for obtaining and refreshing credentials before passing them in.
Create OAuth credentials
Set up an OAuth 2.0 client in the Google Cloud Console. Enable the Google Calendar API for your project and download your client credentials.
Run the OAuth flow
Use
google-auth-oauthlib to complete the consent flow and obtain a Credentials object. The example below shows one way to do this.Constructor
A valid Google OAuth2 credentials object with the
https://www.googleapis.com/auth/calendar scope. Can be loaded from a stored token using Credentials.from_authorized_user_info() or obtained through an OAuth flow.Optional API key for MCP use.
Methods
list_events
List calendar events within a time window. Automatically paginates to fetch all matching events.Start of the time window in ISO 8601 format with timezone (e.g.,
2025-06-01T09:00:00Z or 2025-06-01T09:00:00+05:30).End of the time window in ISO 8601 format with timezone.
Google Calendar ID. Use
"primary" for the user’s main calendar.Maximum number of events to return (1–2500).
Free-text search query to filter events by title, description, or location.
create_event
Create a new calendar event.Event title (the
summary field in Google Calendar).Event start time in ISO 8601 format with timezone.
Event end time in ISO 8601 format with timezone.
Google Calendar ID.
Optional event description.
Optional event location.
find_free_slots
Find available time slots in a calendar within a given window. This checks existing events and returns gaps that are long enough for the requested meeting duration.Start of the search window in ISO 8601 format with timezone.
End of the search window in ISO 8601 format with timezone.
Minimum duration for a free slot, in minutes. Must be greater than 0.
Google Calendar ID.
Maximum number of free slots to return.
window_start, window_end, meeting_minutes, and a free_slots array.
delete_event
Delete a calendar event by its ID.The Google Calendar event ID to delete.
Google Calendar ID.
add_guests
Add guests to an existing calendar event. Duplicate emails are automatically skipped.The Google Calendar event ID.
A list of email addresses to add as attendees.
Google Calendar ID.
Whether to send email invitations to the new guests.
Usage
Basic setup
Finding free time
Creating an event
Full OAuth example
The example below shows a complete flow that handles first-time consent and token refresh. It mirrors the pattern from the Agentor examples folder.Datetime format
All datetime parameters must be in ISO 8601 format with a timezone offset. The tool rejects values without a timezone.| Format | Example |
|---|---|
| UTC | 2025-06-01T09:00:00Z |
| UTC offset | 2025-06-01T14:30:00+05:30 |
| Negative offset | 2025-06-01T09:00:00-04:00 |
Error handling
The tool returns error strings (prefixed withError:) instead of raising exceptions, so your agent can read and react to issues:
- Missing credentials — raises
ValueErrorat construction time - Missing google-api-python-client — raises
ImportErrorat construction time - Invalid datetime — returns
Error: Invalid datetime format... - API errors — returns
Error:with the underlying exception message
Source reference
src/agentor/tools/google_calendar.py:17