Skip to main content
Glama

gmail.users.messages.import

Imports an email message directly into a user's Gmail mailbox for delivery-style scanning and classification without sending it.

Instructions

Imports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. This method doesn't perform SPF checks, so it might not work for some spam messages, such as those attempting to perform domain spoofing. This method does not send a message. Note that the maximum size of the message is 150 MB [HTTP POST] — creates or triggers a change; refused under --readonly safety profiles. Returns the API's response resource as JSON — request body is a JSON Message object accepting classificationLabelValues, historyId, id, internalDate, labelIds, payload, raw, sizeEstimate and 2 more fields; pass it via params or whole via body_file Siblings over the same resource: batchDelete, batchModify, delete, get, insert, list, modify, send, trash, untrash.

Input Schema

NameRequiredDescriptionDefault
queryNoExtra KEY=VALUE query pairs for endpoints whose parameters Discovery does not describe.
paramsNoParameter map merged into the request; typed parameters win.
userIdYes[URL path segment] The user's email address. The special value `me` can be used to indicate the authenticated user.me
deletedNo[query parameter] Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts.false
dry_runNoReturn the request that would be sent, without sending it.
body_fileNoRead the request body from this file ('-' for stdin) instead of building one from the parameters. The body is a JSON Message object.
request_bodyNoRequest body of type Message: pass it via `params` (merged into the built body) or whole via `body_file`.
neverMarkSpamNo[query parameter] Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox.false
internalDateSourceNo[query parameter] Source for Gmail's internal date of the message. Values: `receivedTime` = Internal message date set to current time when received by Gmail.; `dateHeader` = Internal message time based on 'Date' header in email, when valid..dateHeader
processForCalendarNo[query parameter] Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user.false

Output Schema

NameRequiredDescriptionDefault
idNo
rawNo
payloadNo
snippetNo
labelIdsNo
threadIdNo
historyIdNo
internalDateNo
sizeEstimateNo
classificationLabelValuesNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • changedInput schema / properties / body_file / description
      Previous value: -"Read the request body from this file ('-' for stdin) instead of building one from the parameters."New value: +"Read the request body from this file ('-' for stdin) instead of building one from the parameters. The body is a JSON Message object."
    • addedInput schema / properties / request_body
      Added value: +{
      +  "description": "Request body of type Message: pass it via `params` (merged into the built body) or whole via `body_file`.",
      +  "properties": {
      +    "classificationLabelValues": {
      +      "items": {
      +        "properties": {
      +          "fields": {
      +            "items": {
      +              "properties": {
      +                "fieldId": {
      +                  "type": "string"
      +                },
      +                "selection": {
      +                  "type": "string"
      +                }
      +              },
      +              "type": "object"
      +            },
      +            "type": "array"
      +          },
      +          "labelId": {
      +            "type": "string"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "historyId": {
      +      "type": "string"
      +    },
      +    "id": {
      +      "type": "string"
      +    },
      +    "internalDate": {
      +      "type": "string"
      +    },
      +    "labelIds": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "payload": {
      +      "properties": {
      +        "body": {
      +          "properties": {
      +            "attachmentId": {
      +              "type": "string"
      +            },
      +            "data": {
      +              "type": "string"
      +            },
      +            "size": {
      +              "type": "integer"
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "filename": {
      +          "type": "string"
      +        },
      +        "headers": {
      +          "items": {
      +            "properties": {
      +              "name": {
      +                "type": "string"
      +              },
      +              "value": {
      +                "type": "string"
      +              }
      +            },
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "mimeType": {
      +          "type": "string"
      +        },
      +        "partId": {
      +          "type": "string"
      +        },
      +        "parts": {
      +          "items": {
      +            "properties": {
      +              "body": {
      +                "properties": {
      +                  "attachmentId": {
      +                    "type": "string"
      +                  },
      +                  "data": {
      +                    "type": "string"
      +                  },
      +                  "size": {
      +                    "type": "integer"
      +                  }
      +                },
      +                "type": "object"
      +              },
      +              "filename": {
      +                "type": "string"
      +              },
      +              "headers": {
      +                "items": {
      +                  "properties": {
      +                    "name": {
      +                      "type": "string"
      +                    },
      +                    "value": {
      +                      "type": "string"
      +                    }
      +                  },
      +                  "type": "object"
      +                },
      +                "type": "array"
      +              },
      +              "mimeType": {
      +                "type": "string"
      +              },
      +              "partId": {
      +                "type": "string"
      +              },
      +              "parts": {
      +                "items": {
      +                  "properties": {
      +                    "body": {
      +                      "type": "object"
      +                    },
      +                    "filename": {
      +                      "type": "string"
      +                    },
      +                    "headers": {
      +                      "items": {
      +                        "type": "object"
      +                      },
      +                      "type": "array"
      +                    },
      +                    "mimeType": {
      +                      "type": "string"
      +                    },
      +                    "partId": {
      +                      "type": "string"
      +                    },
      +                    "parts": {
      +                      "items": {
      +                        "type": "object"
      +                      },
      +                      "type": "array"
      +                    }
      +                  },
      +                  "type": "object"
      +                },
      +                "type": "array"
      +              }
      +            },
      +            "type": "object"
      +          },
      +          "type": "array"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "raw": {
      +      "type": "string"
      +    },
      +    "sizeEstimate": {
      +      "type": "integer"
      +    },
      +    "snippet": {
      +      "type": "string"
      +    },
      +    "threadId": {
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
  2. Changed11 schema fields changed
    • addedInput schema / properties / deleted / default
      Added value: +"false"
    • changedInput schema / properties / deleted / description
      Previous value: -"Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts."New value: +"[query parameter] Mark the email as permanently deleted (not TRASH) and only visible in Google Vault to a Vault administrator. Only used for Google Workspace accounts."
    • addedInput schema / properties / internalDateSource / default
      Added value: +"dateHeader"
    • changedInput schema / properties / internalDateSource / description
      Previous value: -"Source for Gmail's internal date of the message."New value: +"[query parameter] Source for Gmail's internal date of the message. Values: `receivedTime` = Internal message date set to current time when received by Gmail.; `dateHeader` = Internal message time based on 'Date' header in email, when valid.."
    • addedInput schema / properties / neverMarkSpam / default
      Added value: +"false"
    • changedInput schema / properties / neverMarkSpam / description
      Previous value: -"Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox."New value: +"[query parameter] Ignore the Gmail spam classifier decision and never mark this email as SPAM in the mailbox."
    • addedInput schema / properties / processForCalendar / default
      Added value: +"false"
    • changedInput schema / properties / processForCalendar / description
      Previous value: -"Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user."New value: +"[query parameter] Process calendar invites in the email and add any extracted meetings to the Google Calendar for this user."
    • addedInput schema / properties / userId / default
      Added value: +"me"
    • changedInput schema / properties / userId / description
      Previous value: -"The user's email address. The special value `me` can be used to indicate the authenticated user."New value: +"[URL path segment] The user's email address. The special value `me` can be used to indicate the authenticated user."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "classificationLabelValues": {
      +      "items": {
      +        "properties": {
      +          "fields": {
      +            "items": {
      +              "properties": {
      +                "fieldId": {
      +                  "type": "string"
      +                },
      +                "selection": {
      +                  "type": "string"
      +                }
      +              },
      +              "type": "object"
      +            },
      +            "type": "array"
      +          },
      +          "labelId": {
      +            "type": "string"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "historyId": {
      +      "type": "string"
      +    },
      +    "id": {
      +      "type": "string"
      +    },
      +    "internalDate": {
      +      "type": "string"
      +    },
      +    "labelIds": {
      +      "items": {
      +        "type": "string"
      +      },
      +      "type": "array"
      +    },
      +    "payload": {
      +      "properties": {
      +        "body": {
      +          "properties": {
      +            "attachmentId": {
      +              "type": "string"
      +            },
      +            "data": {
      +              "type": "string"
      +            },
      +            "size": {
      +              "type": "integer"
      +            }
      +          },
      +          "type": "object"
      +        },
      +        "filename": {
      +          "type": "string"
      +        },
      +        "headers": {
      +          "items": {
      +            "properties": {
      +              "name": {
      +                "type": "string"
      +              },
      +              "value": {
      +                "type": "string"
      +              }
      +            },
      +            "type": "object"
      +          },
      +          "type": "array"
      +        },
      +        "mimeType": {
      +          "type": "string"
      +        },
      +        "partId": {
      +          "type": "string"
      +        },
      +        "parts": {
      +          "items": {
      +            "properties": {
      +              "body": {
      +                "properties": {
      +                  "attachmentId": {
      +                    "type": "string"
      +                  },
      +                  "data": {
      +                    "type": "string"
      +                  },
      +                  "size": {
      +                    "type": "integer"
      +                  }
      +                },
      +                "type": "object"
      +              },
      +              "filename": {
      +                "type": "string"
      +              },
      +              "headers": {
      +                "items": {
      +                  "properties": {
      +                    "name": {
      +                      "type": "string"
      +                    },
      +                    "value": {
      +                      "type": "string"
      +                    }
      +                  },
      +                  "type": "object"
      +                },
      +                "type": "array"
      +              },
      +              "mimeType": {
      +                "type": "string"
      +              },
      +              "partId": {
      +                "type": "string"
      +              },
      +              "parts": {
      +                "items": {
      +                  "properties": {
      +                    "body": {
      +                      "type": "object"
      +                    },
      +                    "filename": {
      +                      "type": "string"
      +                    },
      +                    "headers": {
      +                      "items": {
      +                        "type": "object"
      +                      },
      +                      "type": "array"
      +                    },
      +                    "mimeType": {
      +                      "type": "string"
      +                    },
      +                    "partId": {
      +                      "type": "string"
      +                    },
      +                    "parts": {
      +                      "items": {
      +                        "type": "object"
      +                      },
      +                      "type": "array"
      +                    }
      +                  },
      +                  "type": "object"
      +                },
      +                "type": "array"
      +              }
      +            },
      +            "type": "object"
      +          },
      +          "type": "array"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "raw": {
      +      "type": "string"
      +    },
      +    "sizeEstimate": {
      +      "type": "integer"
      +    },
      +    "snippet": {
      +      "type": "string"
      +    },
      +    "threadId": {
      +      "type": "string"
      +    }
      +  },
      +  "type": "object"
      +}
  3. First observed

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are supplied, so the description carries the full burden and does a solid job: it discloses the 150 MB size ceiling, that the message is scanned and classified like SMTP receipt, that SPF checks are skipped so some messages will be rejected, and notably that the call is refused under --readonly safety profiles. Gaps remain around required OAuth scopes / delegation and quota behavior, which matter for a mailbox-mutating call.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the actual purpose and the most decision-relevant facts (no send, no SPF, 150 MB cap) before the generic transport notes. Slightly weakened by boilerplate about HTTP POST and the 'and 2 more fields' enumeration, which add little.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Output schema exists, so return-value explanation is unnecessary, and the description covers the key behavioral caveats (scanning, SPF gap, size limit, readonly refusal) for a mutation tool with a nested request body. More detail on permissions/scope requirements would close the remaining gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents userId, deleted, neverMarkSpam, internalDateSource, processForCalendar, body_file and the full Message body. The description echoes that the body accepts classificationLabelValues, raw, labelIds, etc. and notes '2 more fields', adding little beyond the schema except emphasis on the size limit for the raw message.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (imports) and resource (a message) with explicit scope: 'only this user's mailbox'. It is clearly distinguishable from the sibling 'send' because the description says 'This method does not send a message', and from 'insert' through the SMTP-like delivery scanning framing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage context (SMTP-like delivery scanning, no SPF checks so some spoofed spam may fail, no actual sending) and enumerates the sibling operations over the same resource. However, it never states explicitly when to choose import over insert or send, leaving the agent to infer the routing decision from those hints.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools