communication
Gmail MCP Integration for Claude Agent SDK
Connect Gmail to Claude Agent SDK through the local KosmoKrator MCP gateway with scoped tools, credentials, and write policy.
Connect Gmail to Claude Agent SDK
Give Claude Agent SDK workflows access to KosmoKrator integrations through a local MCP server.
Add a KosmoKrator stdio MCP server to the Claude Agent SDK options. The gateway is local, scoped to this integration, and starts with
--write=deny so Claude Agent SDK can inspect read-capable tools without receiving write access by default.
Gmail MCP Config for Claude Agent SDK
Use a narrow integration list so the agent does not load unrelated tools.
{
"mcpServers": {
"kosmokrator-gmail": {
"type": "stdio",
"command": "kosmo",
"args": [
"mcp:serve",
"--integration=gmail",
"--write=deny"
]
}
}
} Run the Gateway Manually
kosmokrator mcp:serve --integration=gmail --write=deny Why Use KosmoKrator Here
Expose only Gmail instead of a broad multi-service tool list.
Reuse credentials already configured for the KosmoKrator CLI and Lua runtime.
Start read-only, then opt into ask or allow for trusted workspaces.
Gmail Tools Visible to Claude Agent SDK
Claude Agent SDK sees stable MCP tool names generated from the Gmail integration catalog.
| MCP tool | Source function | Type | Description |
|---|---|---|---|
integration__gmail__gmail_add_labels | gmail.gmail_add_labels | Write | Add labels to one or more Gmail messages. Provide messageIds (comma-separated) for batch operations. |
integration__gmail__gmail_archive | gmail.gmail_archive | Read | Archive one or more Gmail messages (remove from inbox). Provide messageIds (comma-separated) for batch operations. |
integration__gmail__gmail_create_draft | gmail.gmail_create_draft | Write | Create a draft email in Gmail (not sent). |
integration__gmail__gmail_mark_read | gmail.gmail_mark_read | Write | Mark one or more Gmail messages as read. Provide messageIds (comma-separated) for batch operations. |
integration__gmail__gmail_mark_unread | gmail.gmail_mark_unread | Write | Mark one or more Gmail messages as unread. Provide messageIds (comma-separated) for batch operations. |
integration__gmail__gmail_read | gmail.gmail_read | Read | 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. |
integration__gmail__gmail_remove_labels | gmail.gmail_remove_labels | Write | Remove labels from one or more Gmail messages. Provide messageIds (comma-separated) for batch operations. |
integration__gmail__gmail_reply | gmail.gmail_reply | Read | Reply to an existing Gmail message (maintains the thread). |
integration__gmail__gmail_count_by_sender | gmail.gmail_count_by_sender | Read | 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". |
integration__gmail__gmail_list_labels | gmail.gmail_list_labels | Read | List all labels in the Gmail mailbox (INBOX, SENT, custom labels, etc.). |
integration__gmail__gmail_save_attachment | gmail.gmail_save_attachment | Read | 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. |
integration__gmail__gmail_search_emails | gmail.gmail_search_emails | Read | 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. |
integration__gmail__gmail_send_draft | gmail.gmail_send_draft | Write | Send a previously created Gmail draft by its ID. |
integration__gmail__gmail_send_email | gmail.gmail_send_email | Write | Send an email directly via Gmail. |
integration__gmail__gmail_trash | gmail.gmail_trash | Read | Move one or more Gmail messages to trash. Provide messageIds (comma-separated) for batch operations. |
integration__gmail__gmail_untrash | gmail.gmail_untrash | Read | Remove one or more Gmail messages from trash. Provide messageIds (comma-separated) for batch operations. |