gmail-mcp
Servidor MCP de Gmail
El servidor MCP de Gmail es un servidor MCP stdio basado en Node.js/TypeScript, diseñado para permitir que OpenClaw lea correos electrónicos de Gmail a través del Protocolo de Contexto de Modelo (MCP).
Funcionalidades
Utiliza la autorización OAuth 2.0 de la API de Gmail, con un alcance de solo lectura:
https://www.googleapis.com/auth/gmail.readonlylist_emails: lista los correos de la bandeja de entrada, admitemaxResultsy filtrado mediante la sintaxis de búsqueda de Gmailqueryget_email: lee los detalles de un correo electrónico específico mediante sumessageIdsearch_emails: busca correos electrónicos utilizando la sintaxis de búsqueda de Gmaillist_labels: lista todas las etiquetas/carpetas de GmailAdmite el transporte stdio de MCP, permitiendo su invocación por parte de OpenClaw
Related MCP server: gmail-mcp
Requisitos del entorno
Node.js 18 o superior
npm
Una cuenta de Google con acceso a la API de Gmail
Instalación
npm install
npm run buildCrear credenciales OAuth en Google Cloud Console
Abre Google Cloud Console.
Crea o selecciona un proyecto.
Ve a
APIs & Services->Library, busca y habilita laGmail API.Ve a
APIs & Services->OAuth consent screen.Selecciona el tipo de usuario. Para uso personal, generalmente se elige
External.Completa el nombre de la aplicación, el correo electrónico de soporte al usuario y el correo electrónico de contacto del desarrollador.
En el paso de Scopes (ámbitos), añade el permiso de solo lectura de Gmail:
https://www.googleapis.com/auth/gmail.readonly.Si la aplicación está en estado de Testing, añade tu cuenta de Gmail en Test users.
Ve a
APIs & Services->Credentials.Haz clic en
Create Credentials->OAuth client ID.En Application type, selecciona
Desktop app.Descarga el archivo JSON después de crearlo.
Colocar credentials.json
Crea el directorio de configuración y guarda el JSON de OAuth descargado como:
mkdir -p ~/.gmail-mcp
chmod 700 ~/.gmail-mcp
cp /path/to/downloaded/client_secret.json ~/.gmail-mcp/credentials.json
chmod 600 ~/.gmail-mcp/credentials.jsonLa ruta final debe ser:
~/.gmail-mcp/credentials.jsonEjecutar el flujo de autorización
npm run authEl script realizará lo siguiente:
Iniciará un servicio de callback OAuth local temporal
Abrirá el navegador para realizar la autorización de Google
Guardará el token en
~/.gmail-mcp/token.jsonuna vez completada la autorización
Si el navegador no se abre automáticamente, la terminal imprimirá la URL de autorización; simplemente cópiala y pégala en tu navegador.
Iniciar el servidor MCP
npm run startstart utiliza el transporte stdio, generalmente iniciado por OpenClaw como un subproceso del servidor MCP, por lo que no es necesario ejecutarlo manualmente de forma prolongada.
Ejemplo de configuración de OpenClaw MCP
Apunta el comando al punto de entrada compilado del proyecto:
{
"mcpServers": {
"gmail": {
"command": "node",
"args": ["/Volumes/DevDisk/symbol/gmailMCP/dist/src/index.js"]
}
}
}También puedes iniciarlo con npm dentro del directorio del proyecto:
{
"mcpServers": {
"gmail": {
"command": "npm",
"args": ["run", "start"],
"cwd": "/Volumes/DevDisk/symbol/gmailMCP"
}
}
}Descripción de los parámetros de las herramientas
list_emails
Lista los correos electrónicos de la bandeja de entrada.
{
"maxResults": 10,
"query": "from:example@gmail.com newer_than:7d"
}maxResults: opcional, predeterminado10, máximo50query: opcional, sintaxis de búsqueda de Gmail, limitará la consulta a la bandeja de entrada (INBOX)
get_email
Lee los detalles de un correo electrónico específico.
{
"messageId": "18f..."
}Los campos devueltos incluyen remitente, destinatario, asunto, fecha, etiquetas, cuerpo de texto, cuerpo HTML y metadatos de archivos adjuntos.
search_emails
Busca correos electrónicos en Gmail.
{
"query": "subject:invoice has:attachment newer_than:30d",
"maxResults": 10
}query: obligatorio, admite la sintaxis de búsqueda de GmailmaxResults: opcional, predeterminado10, máximo50
list_labels
Lista todas las etiquetas/carpetas.
{}Ubicación de archivos
Credenciales OAuth:
~/.gmail-mcp/credentials.jsonToken OAuth:
~/.gmail-mcp/token.jsonPunto de entrada del servidor MCP:
dist/src/index.js
Preguntas frecuentes
Missing Gmail OAuth credentials
Confirma que has descargado el JSON del cliente OAuth de Google y lo has guardado en:
~/.gmail-mcp/credentials.jsonMissing Gmail OAuth token
Ejecuta primero:
npm run authaccess_denied o aplicación no verificada
Si la pantalla de consentimiento de OAuth sigue en estado Testing, debes añadir tu cuenta de Gmail actual a los Test users.
invalid_grant
Elimina el token antiguo y vuelve a autorizar:
rm ~/.gmail-mcp/token.json
npm run authAvailable Tools
4 toolsget_emailA
Read one Gmail message by messageId.
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | Gmail message id. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must disclose behavioral traits. It states 'Read,' which implies a read-only operation with no side effects, but does not detail error handling, permissions required, or what the response contains. This is minimally adequate for a simple read tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, well-structured sentence with no unnecessary words. It is front-loaded with the verb and resource, making it efficient for an agent to parse.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (one parameter, no output schema), the description is largely complete. It could be improved by briefly noting what the tool returns (e.g., message content or metadata), but it still provides enough context for basic usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage for the single parameter (messageId: 'Gmail message id.'). The description adds no further meaning beyond what the schema already provides, so it meets the baseline of 3.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses the specific verb 'Read' and clearly identifies the resource as 'one Gmail message by messageId.' It distinguishes from siblings like list_emails (list multiple) and search_emails (search), making the tool's purpose unambiguous.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies that the tool is used when you have a specific messageId, but it does not explicitly state when to use it versus alternatives (e.g., list_emails for browsing, search_emails for filtering). No exclusions or prerequisites are mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_emailsB
List Gmail inbox messages. Supports maxResults and Gmail query filters.
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of emails to return. Default 10, max 50. | |
| query | No | Optional Gmail search query, applied within INBOX. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description must disclose behavior. Mentions it lists inbox messages and supports parameters, but no details on pagination, response format, or conditions like invalid queries. For a read operation, minimal disclosure.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, no filler. Efficiently conveys the core purpose and supported features.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple tool with 2 params and no output schema, the description covers basics but lacks usage guidelines and behavioral details, leaving gaps for an AI agent to make informed decisions.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with clear parameter descriptions (maxResults: default, min, max; query: optional within INBOX). Description merely restates that parameters are supported, adding no new semantic meaning beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states 'List Gmail inbox messages' with verb and resource, distinguishing from get_email (single email) and list_labels (labels). However, does not explicitly differentiate from search_emails, which may also list emails but with different scope.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance on when to use this tool vs alternatives like search_emails. Only states what it does, leaving the agent to infer usage context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_labelsA
List all Gmail labels and folders.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description is the sole source. It states the action but lacks details like pagination, data scope, or authentication requirements. For a simple list, this is adequate but minimal.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single, front-loaded sentence contains all necessary information without waste.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's simplicity (0 parameters, no output schema) and clear sibling differentiation, the description is complete enough for an agent to use correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has no parameters and 100% coverage. With 0 parameters, the baseline is 4, and the description does not add parameter information beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'List all Gmail labels and folders' uses a specific verb and resource, clearly distinguishing from sibling tools that deal with emails (get_email, list_emails, search_emails).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
While no explicit when-to-use or alternatives are stated, the sibling context makes it clear this is for labels/folders vs. emails, implying appropriate usage.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_emailsA
Search Gmail messages with Gmail search syntax.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Gmail search query string. | |
| maxResults | No | Maximum number of emails to return. Default 10, max 50. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description bears full burden. It only mentions search syntax, but does not disclose output format, error behavior, or whether results include full messages or metadata.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence with no redundancy. Every word adds meaning.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Lacks details on return format (e.g., fields, pagination) and how it differs from list_emails. No output schema, so description should provide more context.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100%, so baseline is 3. Description adds value by specifying query uses 'Gmail search syntax', which is essential for correct invocation.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states verb (Search) and resource (Gmail messages) using specific syntax. Distinguishes from sibling tools like get_email (single) and list_labels.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use search vs alternatives like list_emails or get_email. The description is minimally adequate but lacks contextual differentiation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
4 tool updates
v0.0.1- First observed
get_email - First observed
list_emails - First observed
list_labels - First observed
search_emails
TDQS
Scored across 4 tools
Each tool targets a distinct operation: reading a single email by ID, listing inbox messages, searching with Gmail syntax, and listing labels. There is no overlap in functionality.
All tool names follow the consistent verb_noun pattern in snake_case: get_email, list_emails, list_labels, search_emails.
With 4 tools, the set is concise and scoped to basic read and list operations. While it covers common use cases, it could be expanded with write operations, but the count is reasonable for a focused subset.
The tool surface lacks write operations such as sending, deleting, or modifying emails and labels. Users cannot perform actions beyond reading and listing, which is a significant gap for comprehensive Gmail management.
Maintenance
Related MCP Connectors
- MailowsOAuthcom.mailows
Give AI agents their own email inboxes: list, read and send mail via scoped, revocable OAuth grants.
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides comprehensive Gmail integration with LLM processing capabilities, allowing users to read, search, filter emails and handle attachments through the Model Context Protocol.25 npm2MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables full management of Gmail accounts, including messages, threads, labels, and drafts. It leverages the Gmail API to allow searching, sending, and organizing emails via secure OAuth2 authentication.MIT
- FlicenseNot gradedqualityDmaintenanceProvides access to Gmail functionality through the Model Context Protocol, allowing LLMs like Claude to interact with your email.2-
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to manage Gmail through natural language, including search, read, send, label, and draft operations via the Model Context Protocol.-