Skip to main content
Glama

upload_document

Destructive

Attach an actual FILE to a record (lead/contact/account/campaign) — stored in private Supabase Storage, not just a URL reference. Required: entity, entity_id, and EITHER source_url OR content_base64 (not both).

IF YOU HAVE SHELL/CODE-EXECUTION ACCESS (Bash, a script runner, etc.) AND THE FILE IS ONLY ON LOCAL DISK: do NOT use content_base64 here. Use create_document_upload_url + finalize_document_upload instead — that flow lets your shell do a plain HTTP PUT of the raw bytes, which costs you ZERO context/output tokens, no matter the file size. Reserve content_base64 on THIS tool for content so small you already have it as text in your own context anyway (a few KB at most) — generating a large base64 string as your own output defeats the point of having shell access.

PREFER source_url when the file already has a stable URL (the server fetches it directly — also zero cost to you). Use content_base64 only for genuinely tiny content with no reachable URL and no shell access. filename is required with content_base64, optional with source_url (derived from the URL).

Optional either way: mime_type, doc_type (default 'file'), title (default filename), description, amount, currency, status, occurred_at, analyze (default true — runs AI analysis synchronously and writes a summary into description; set false to skip). AI analysis extracts text from PDF, Word (.docx), Excel (.xlsx, one Markdown table per sheet), PowerPoint/OpenDocument and txt/md/csv/json/html, stores it (read it back with get_document_text) and indexes it for search_knowledge — images, scans and old .doc/.xls store fine but return analyzed:false with a reason (use run_document_step vision_ocr for scans). Returns { document_id, storage_path, mime_type, file_size, analyzed, description? }.

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": {
      "entity": "<entity>",
      "entity_id": "<entity_id>"
    },
    "name": "upload_document"
  }
}

Input Schema

NameRequiredDescriptionDefault
titleNoTitle of the document
amountNoAmount
entityYesRecord type the file is attached to: lead, contact, account or campaign
statusNoInitial status
analyzeNoRun AI text-extraction + summary synchronously after upload (default true).
currencyNoCurrency code (ISO 4217, e.g. EUR)
doc_typeNoType of document
filenameNoRequired with content_base64; optional with source_url (derived from the URL if omitted).
entity_idYesID of the record
mime_typeNoMIME type of the file
source_urlNoURL the server fetches directly — no base64/context cost. Preferred when the file already has a stable URL.
descriptionNoDescription of the document
occurred_atNoWhen it happened (ISO 8601)
content_base64NoRaw file bytes, base64-encoded. Only for tiny content (a few KB) with no reachable URL and no shell access — see create_document_upload_url for local files.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed10 schema fields changed
    • addedInput schema / properties / amount / description
      Added value: +"Amount"
    • addedInput schema / properties / currency / description
      Added value: +"Currency code (ISO 4217, e.g. EUR)"
    • addedInput schema / properties / description / description
      Added value: +"Description of the document"
    • addedInput schema / properties / doc_type / description
      Added value: +"Type of document"
    • addedInput schema / properties / entity / description
      Added value: +"Record type the file is attached to: lead, contact, account or campaign"
    • addedInput schema / properties / entity_id / description
      Added value: +"ID of the record"
    • addedInput schema / properties / mime_type / description
      Added value: +"MIME type of the file"
    • addedInput schema / properties / occurred_at / description
      Added value: +"When it happened (ISO 8601)"
    • addedInput schema / properties / status / description
      Added value: +"Initial status"
    • addedInput schema / properties / title / description
      Added value: +"Title of the document"
  2. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare destructiveHint=true and idempotentHint=false, but the description adds substantial behavior: files land in private Supabase Storage, AI analysis runs synchronously and writes into description, analysis is skipped/failed for images, scans and legacy .doc/.xls with analyzed:false plus a reason, and it names run_document_step vision_ocr as the fallback. It also documents the return payload.

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 core verb and required inputs before the cost-optimization advice, and the uppercase emphasis on the shell-access case is well placed. It loses a point for restating the source_url preference twice ('PREFER source_url...' after already saying 'EITHER source_url OR content_base64 (not both)'), which makes the middle paragraphs heavier than necessary.

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 14-parameter mutation tool with no output schema, the description covers required inputs, the exclusive source parameter, defaults, synchronous side effects, failure modes and the return shape — everything an agent needs to call it correctly on the first try.

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 explains 14 params; the description still adds real semantics the schema lacks — the source_url/content_base64 mutual exclusivity, filename being required only with base64 and derived from the URL otherwise, and the defaults for doc_type, title and analyze. It does not, however, add meaning to the looser fields like amount, currency or status.

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+resource ('Attach an actual FILE to a record') and enumerates the target entity types, then immediately distinguishes it from a URL-only reference tool. The contrast with create_document_upload_url/finalize_document_upload makes its niche unmistakable among the upload siblings.

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?

Explicit when-to-use routing: use this tool only when the file is a stable URL or genuinely tiny inline text; use create_document_upload_url + finalize_document_upload when the file is on local disk with shell access. It also states the either/or requirement (source_url XOR content_base64) and when analyze should be turned off.

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.