Microsoft Graph
Outlook Mail, Outlook Calendar, and Microsoft Files toolsets.
#Microsoft Graph connectors
Three connectors cover the Microsoft 365 / Outlook surfaces most agents need:
OutlookMailToolSet— mail.OutlookCalendarToolSet— calendars and events.MicrosoftFilesToolSet— OneDrive and SharePoint documents.
All three authenticate with an Azure AD-issued OAuth 2.0 bearer token. Use OAuth2Flow against the v2 endpoint:
from maivn_tools import OAuth2EndpointConfig, OAuth2Flow
flow = OAuth2Flow(
client_id=AZURE_CLIENT_ID,
client_secret=AZURE_CLIENT_SECRET,
endpoints=OAuth2EndpointConfig(
authorize_url=f"https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/authorize",
token_url=f"https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token",
),
)The connectors accept a token string, an OAuth2Token, or a callable returning one — the same shape as the Google Workspace connectors.
Agent-ready pattern. Across the three connectors, list / search tools return compact human-readable summaries by default with a response-local_reffield (folder_ref,message_ref,calendar_ref,event_ref,item_ref). Default page size is 25. Raw Graph GUIDs are hidden unless you passinclude_ids=True; passinclude_metadata=Falseto get the raw Graph response with every field. Write tools that target a single item (get_message,move_message,delete_message,update_event,delete_event,download_file,delete_item, ...) accept either a raw ID string or the summary dict from the corresponding list/search tool — the connector extracts the ID for you. Well-known folder names (inbox,drafts,sentitems,deleteditems,junkemail,outbox,archive) are also accepted whereverfolder_idis expected.
#OutlookMailToolSet
from maivn_tools import OutlookMailToolSet
mail = OutlookMailToolSet(token=token_cache)The connector defaults to me as the user identifier; pass user="ops@example.test" to act against a different mailbox when the token has the required admin scope.
#Agent-ready behavior
list_folders returns folder_ref summaries with display_name, total_item_count, unread_item_count. search_messages and list_messages_in_folder return message_ref summaries with sender, to-list, subject, received_at, preview (Graph's bodyPreview), and is_read. Default top is 25. Raw Graph IDs are hidden unless include_ids=True; include_metadata=False returns the raw Graph response.
outlook_mail.search_messages(search="invoice")
# { "messages": [{"message_ref": "message_1",
# "sender": "Alice <alice@example>",
# "subject": "May invoice", "received_at": "...",
# "preview": "...", "is_read": false}],
# "nextLink": null }get_message, move_message, copy_message, update_message, mark_read, flag_message, reply_to_message, forward_message, list_attachments, add_attachment, delete_message, and send_draft all accept either a raw message_id string or a message dict from a list response. folder_id arguments (list_messages_in_folder, move_message, etc.) accept a raw ID, a folder dict, or a well-known name (inbox, drafts, ...).
#Destructive tools
delete_message, delete_folder, and delete_mail_rule are tagged destructive=True. delete_message moves the message to Deleted Items (recoverable from there); delete_folder removes the folder and all messages it contains. Confirm with the user before invoking.
#OutlookCalendarToolSet
#Agent-ready behavior
list_calendars returns calendar_ref summaries with name, color, is_default, can_edit. list_events and list_event_instances return event_ref summaries with subject, start/end times, location (display name), organizer, attendees, is_online_meeting, is_all_day. Default top is 25. Raw Graph event/calendar IDs are hidden unless include_ids=True; include_metadata=False returns the raw Graph response. get_calendar accepts a raw ID, a calendar dict, or the literal "primary".
outlook_calendar.list_events(start="2026-05-16T00:00:00",
end="2026-05-17T00:00:00")
# { "events": [{"event_ref": "event_1", "subject": "Standup",
# "start_time": "...", "end_time": "...",
# "organizer": "Alice <...>", "attendees": [...],
# "is_online_meeting": true}] }get_event, update_event, respond_to_event, cancel_event, forward_event, delete_event, and list_event_instances all accept either a raw event_id string or an event dict from list_events. calendar_id similarly accepts raw IDs or calendar dicts.
#Destructive tools
delete_event and delete_calendar are tagged destructive=True. cancel_event sends cancellation notices and is irreversible in effect — confirm with the user before calling.
#MicrosoftFilesToolSet
from maivn_tools import MicrosoftFilesToolSet
drive = MicrosoftFilesToolSet(token=token_cache, drive_root="me/drive")
sharepoint = MicrosoftFilesToolSet(token=token_cache, drive_root="sites/<site-id>/drive")#Agent-ready behavior
list_root_children, list_children, and search_files return compact summaries by default. Each item has item_ref (or folder_ref for folders), name, kind (file / folder), size, modified_time, owner, web_url, and mime_type for files. Default top is 25. Raw Graph item IDs are hidden unless include_ids=True; include_metadata=False returns the raw provider response.
ms_files.search_files("invoice")
# { "items": [{"item_ref": "item_1", "name": "May invoice.xlsx",
# "kind": "file", "size": 12345,
# "modified_time": "...", "owner": "Alice",
# "web_url": "https://...",
# "mime_type": "application/vnd.openxmlformats-..."}],
# "next_link": null }get_item, download_file, list_children, list_versions, list_permissions, rename_item, update_item_metadata, move_item, copy_item, restore_version, create_share_link, invite_to_item, and delete_item all accept either a raw item ID string or the item dict from search_files / list_root_children / list_children.
#Destructive tools
delete_item and revoke_permission are tagged destructive=True. delete_item moves the item to the user's recycle bin (recoverable from there); revoke_permission removes a share with no undo. Confirm with the user before invoking.
#Filtering at registration
# Read-only Outlook for a triage agent.
agent.add_toolset(OutlookMailToolSet(token=cache), include_tags=["read"])
# Calendar without destructive operations.
agent.add_toolset(OutlookCalendarToolSet(token=cache), exclude_tags=["destructive"])
# Drive read + safe writes only (no deletes, no permission revocation).
agent.add_toolset(MicrosoftFilesToolSet(token=cache), exclude_tags=["destructive"])See Writing your own toolset for the full filter API.
#Scopes
The connectors advertise the standard Graph scopes through metadata.scopes. At minimum, request the *.Read scope for read-only agents and *.ReadWrite for write tools. SharePoint Files require the Sites.Read.All / Sites.ReadWrite.All scopes on the application registration.