Skip to main content
Glama

Store a mail attachment as a document

well_create_document_from_mail_attachment
Idempotent

Store one attachment of one message of the caller's own Gmail or Outlook as a document of this workspace, and return its document_id. Use it after well_search_mailbox_for_receipt found the message that fits, when its already_in_well is false, to get a stored document that another tool takes (for example well_link_receipt_to_transaction). Pass the match's provider, mailbox and message_id exactly as returned. Leave filename null: a message with one file attachment stores it; a message with several returns attachment_choice_needed with candidates (file name, size, type): pick the one that fits, or ask the person, then call again with its filename and size.

The write stays inside Well: it sends nothing, changes nothing in the mailbox and reads only the caller's own mailboxes. The document then goes through the same reading as an uploaded file.

Returns outcome: "created" (a new document), "already_stored" (the same file was already a document; its id is returned), "attachment_choice_needed", "attachment_not_found" (no file attachment, or none with that name and size; candidates lists what the message holds), "message_not_found", "mailbox_not_found" (the caller has no live mailbox of that provider and address here), "needs_reconnect", "too_large", "type_refused" or "unavailable". Only "created" and "already_stored" carry a document_id; never say a file is stored on any other outcome.

When the token authorizes one workspace, call this directly — no workspace call is needed first. When it authorizes several, this read will not guess which one you mean: pass workspace_id on the call.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "provider": "<provider>",
      "message_id": "<message_id>"
    },
    "name": "well_create_document_from_mail_attachment"
  }
}

Input Schema

NameRequiredDescriptionDefault
sizeNoThe attachment's size in bytes, from `candidates`. It tells apart two attachments that share a name.
mailboxNoThe match's `mailbox` address, as returned. Pass null only when it returned null.
filenameNoThe attachment's file name. Leave null on the first call; pass one of the returned `candidates` when the answer is attachment_choice_needed.
providerYesThe match's `provider`, as well_search_mailbox_for_receipt returned it.
message_idYesThe match's `message_id`, as returned.
workspace_idNoTarget workspace. Omit when the token authorizes one workspace. Required when it authorizes several — a write lands in exactly one workspace and this call would not say which.
conversation_idNoThe conversation id returned by the previous Well result, in its meta under well/conversation_id, in its structuredContent, or in its JSON text block. Pass it back on every call in the same conversation, including a call a card makes, so the chosen workspace and the earlier answers still apply. It decides the conversation on its own: nothing the host states about the session replaces it. Omit it only on the first call of a conversation.
idempotency_keyNoOptional client-supplied key. A retried write with the same key returns the original result instead of re-applying the operation.
workspace_scopeNoRestrict this call to the family: the token's primary workspace plus the company workspaces under it that you are a member of. Unrelated authorized workspaces drop out of the read; row reads merge across the family, while a per-workspace figure still reports exactly one workspace.

Output Schema

NameRequiredDescriptionDefault
errorNo
outcomeNo
successYes
attachmentNo
candidatesNo
document_idNo
conversation_idNoThe conversation this result belongs to. Pass it back as the conversation_id argument on every later Well call in the same conversation.
newly_connectedNoTools that connected to this workspace since the last result and that no session was told about yet, oldest first. Present only when at least one tool is new. The connected-line rule says when to tell an entry; when it does, one line per entry, in the person's language: "<name> is connected.". Never fold several entries into one sentence. Each entry comes back once, on one result only: never repeat its line later.
resolved_workspaceNoThe workspace that answered, when the caller named none and the token authorizes several.
conversation_id_noteNoPresent only when the server opened a fresh lane, stating that no choice recorded earlier was read.
conversation_id_sourceNoWhere the conversation id came from: the host's own request meta, the caller's argument, or a fresh lane the server opened.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.8/5.0
Behavior5/5

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

Beyond the annotations (readOnly=false, destructive=false, idempotent=true, openWorld=true), it discloses that the write stays inside Well, sends nothing, changes nothing in the mailbox and reads only the caller's own mailboxes. It then enumerates every possible `outcome` and adds a safety rule ('never say a file is stored on any other outcome') plus the fact that the stored document goes through the same reading as an uploaded file.

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?

The primary action and its prerequisite are front-loaded, and the outcome enumeration is compact given how many states exist. It runs long and the closing paragraph on workspace selection partly restates the `workspace_id` schema text, which is the only real waste.

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

Completeness5/5

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

For a nine-parameter, multi-step, cross-system write with retry semantics, the description covers the prerequisite call, the retry loop, the workspace/conversation requirements, the side-effect boundary and the full outcome space. Even though an output schema exists, the outcome enumeration adds decision-relevant guidance an agent needs to avoid misreporting success.

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

Parameters4/5

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

Schema coverage is 100%, so the schema already documents all nine parameters and the baseline would be 3. The description still adds real meaning: pass `provider`, `mailbox` and `message_id` 'exactly as returned', leave `filename` null on the first call and only supply it from `candidates` on retry, and pass `workspace_id` only when multiple workspaces are authorized. It does not re-explain `size`, `idempotency_key`, `conversation_id` or `workspace_scope`, which the schema covers.

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?

The description opens with a specific verb, resource and scope: 'Store one attachment of one message of the caller's own Gmail or Outlook as a document of this workspace, and return its `document_id`.' It is clearly separable from siblings — it names well_search_mailbox_for_receipt as the prerequisite and well_link_receipt_to_transaction as a downstream consumer, and implicitly distinguishes itself from well_upload_document by specifying the mail-attachment source.

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

Usage Guidelines5/5

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

It gives an explicit trigger condition ('Use it after well_search_mailbox_for_receipt found the message that fits, when its `already_in_well` is false') and names the follow-on tool that consumes the result. It also states the multi-step retry path for `attachment_choice_needed` and the workspace/conversation conditions under which to call directly versus pass `workspace_id`.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources