Gmail Connector
OAuth-connected Gmail search, message/thread retrieval, and draft creation.
Credential setup
oauth2Request gmail.readonly and gmail.compose only when draft creation is enabled.
Setup docs: https://console.cloud.google.com/apis/credentials
After adding this connector, attach the credential on the server page, then run astrail tools list.
Hosted MCP endpoint
/api/mcp/preset-gmailPrivate servers require an Astrail API key in the Authorization header.
MCP client snippets
ConnectClaude Desktop config
{
"mcpServers": {
"gmail-connector": {
"url": "/api/mcp/preset-gmail"
}
}
}cURL initialize
curl -sS -X POST "/api/mcp/preset-gmail" \
-H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'cURL tools/list
curl -sS -X POST "/api/mcp/preset-gmail" \
-H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'cURL tools/call
curl -sS -X POST "/api/mcp/preset-gmail" \
-H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"gmail_search_messages","arguments":{"q":"example","maxResults":"example","pageToken":"example"}}}'Runtime behavior
healthynot_checkedsafe_rest_executionnot recordednot recordednot recordednonestructured fallbackstandardauth_required / oauth_requiredmapping_requiredAstrail does not evaluate generated TypeScript inside Next.js. Hosted calls are routed through stored tool metadata and endpoint maps.
Tools
8gmail_search_messagesSearch Gmail messages using Gmail query syntax.
gmail_get_messageRetrieve a Gmail message.
gmail_get_threadRetrieve a Gmail thread.
gmail_create_draftCreate a Gmail draft from a base64url encoded RFC 2822 message.
gmail_get_profileGet the connected Gmail mailbox profile and history cursor.
gmail_list_labelsList labels in the connected Gmail mailbox.
gmail_list_draftsList Gmail drafts with pagination.
gmail_get_draftRetrieve a Gmail draft by ID.
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({ name: "Gmail Connector", version: "1.0.0" });
// Curated Astrail connector for: gmail_search_messages, gmail_get_message, gmail_get_thread, gmail_create_draft, gmail_get_profile, gmail_list_labels, gmail_list_drafts, gmail_get_draft.
// The hosted endpoint executes its verified deterministic endpoint map. Attach a least-privilege provider credential before calling private tools.
server.tool("connector_status", "Confirm this curated connector template is installed.", z.object({}), async () => ({
content: [{ type: "text", text: "Connector installed. Attach provider credentials to enable hosted API calls." }],
}));
const transport = new StdioServerTransport();
await server.connect(transport);