KosmoKrator

productivity

Gmail MCP, CLI, and Lua Integration for AI Agents

Gmail integration docs for AI agents: MCP gateway setup, Gmail CLI commands, Lua API reference, credentials, and function schemas.

Gmail for agents

OAuth can be configured in web hosts through redirect and in CLI hosts through local/device authorization; runtime works with stored tokens.

Use this integration from Lua code mode, the headless integrations CLI, or the KosmoKrator MCP gateway. The same package metadata powers all three surfaces.

Agent Surfaces

Machine-Readable Metadata

Function Catalog

FunctionTypeParametersDescription
gmail.gmail_add_labels Write write 3 Add labels to one or more Gmail messages. Provide messageIds (comma-separated) for batch operations.
gmail.gmail_archive Read read 2 Archive one or more Gmail messages (remove from inbox). Provide messageIds (comma-separated) for batch operations.
gmail.gmail_create_draft Write write 5 Create a draft email in Gmail (not sent).
gmail.gmail_mark_read Write write 2 Mark one or more Gmail messages as read. Provide messageIds (comma-separated) for batch operations.
gmail.gmail_mark_unread Write write 2 Mark one or more Gmail messages as unread. Provide messageIds (comma-separated) for batch operations.
gmail.gmail_read Read read 2 Read the full content of a Gmail message by its ID. Returns headers (From, To, Subject, Date), the decoded text body, and a list of attachments. Use gmail_search first to find message IDs, then use this tool to read the full content.
gmail.gmail_remove_labels Write write 3 Remove labels from one or more Gmail messages. Provide messageIds (comma-separated) for batch operations.
gmail.gmail_reply Read read 6 Reply to an existing Gmail message (maintains the thread).
gmail.gmail_count_by_sender Read read 2 Count all matching Gmail messages grouped by sender. Automatically paginates through ALL results (handles thousands of messages). Returns top senders sorted by count. Use for questions like "who sends me the most email?" or "count unread by sender".
gmail.gmail_list_labels Read read 0 List all labels in the Gmail mailbox (INBOX, SENT, custom labels, etc.).
gmail.gmail_save_attachment Read read 4 Download an email attachment and save it to workspace files. Requires a messageId and attachmentId (both returned by gmail_read). The file is saved under the agent's folder and can be browsed in the Files page.
gmail.gmail_search_emails Read read 4 Search Gmail messages using Gmail query syntax (e.g., "from:alice subject:meeting is:unread has:attachment after:2026-02-01"). Returns message summaries with headers. Max 100 per page.
gmail.gmail_send_draft Write write 1 Send a previously created Gmail draft by its ID.
gmail.gmail_send_email Write write 5 Send an email directly via Gmail.
gmail.gmail_trash Read read 2 Move one or more Gmail messages to trash. Provide messageIds (comma-separated) for batch operations.
gmail.gmail_untrash Read read 2 Remove one or more Gmail messages from trash. Provide messageIds (comma-separated) for batch operations.