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.
1
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.
2
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.3
Pass credentials to CalendarTool
Provide the resulting
Credentials object when creating the tool.Constructor
google.oauth2.credentials.Credentials
required
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.str
Optional API key for MCP use.
Methods
list_events
List calendar events within a time window. Automatically paginates to fetch all matching events.str
required
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).str
required
End of the time window in ISO 8601 format with timezone.
str
default:"primary"
Google Calendar ID. Use
"primary" for the user’s main calendar.int
default:"20"
Maximum number of events to return (1–2500).
str
Free-text search query to filter events by title, description, or location.
create_event
Create a new calendar event.str
required
Event title (the
summary field in Google Calendar).str
required
Event start time in ISO 8601 format with timezone.
str
required
Event end time in ISO 8601 format with timezone.
str
default:"primary"
Google Calendar ID.
str
Optional event description.
str
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.str
required
Start of the search window in ISO 8601 format with timezone.
str
required
End of the search window in ISO 8601 format with timezone.
int
default:"30"
Minimum duration for a free slot, in minutes. Must be greater than 0.
str
default:"primary"
Google Calendar ID.
int
default:"10"
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.str
required
The Google Calendar event ID to delete.
str
default:"primary"
Google Calendar ID.
add_guests
Add guests to an existing calendar event. Duplicate emails are automatically skipped.str
required
The Google Calendar event ID.
list
required
A list of email addresses to add as attendees.
str
default:"primary"
Google Calendar ID.
bool
default:"True"
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.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