Skip to main content
Glama

gemini_upload_file

Upload a file — an image, reference photo, picture, screenshot, video or audio clip — to the Gemini Files API ONCE, and get back a reusable file_uri (files/<id>) to attach to later image, video or music generations.

Instructions

Upload a file — an image, reference photo, picture, screenshot, video or audio clip — to the Gemini Files API ONCE, and get back a reusable file_uri (files/<id>) to attach to later image, video or music generations. Keywords: upload, upload file, upload image, upload photo, attach, reference image, reference photo, file_uri, files api, image reference, reuse across calls. Use this instead of pasting base64 into a tool call: the reference is a short string, so no image bytes ever enter the conversation, and it can be reused across many generations until it expires (~48h). Provide exactly one of url (the server downloads it), data_base64, or path (a local file). A local path is confirmed first: a confirmation prompt where the client supports one; otherwise the first call returns a preview and a confirmToken, and only a repeat call with that token proceeds (see MCP_CONFIRM_MODE).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoPublic https URL the SERVER downloads and uploads (image/video/audio, up to 100MB). No bytes pass through the conversation.
pathNoPath to a local file (absolute, or resolved against $GEMINI_INPUT_DIR). Confirm-gated like every other local-file input.
r2_keyNoUnavailable on this server (media is written to local disk) — pass the file path via `path` instead.
mime_typeNoOverride the detected MIME type (sniffed from the bytes / taken from the server response otherwise)
data_base64NoRaw base64 or a data: URI. Last resort — this is the one form that costs model context (~14k tokens for a modest JPEG).
confirmTokenNoONLY for the two-step confirmation fallback (a client without MCP elicitation). The confirmToken from this same tool's phase-1 "confirmation-required" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat — never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.
display_nameNoHuman-readable name recorded against the upload

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv2.3.0
    • removedInput schema / properties / confirm
      Removed value: -{
      -  "description": "Must be true to proceed. Without this, the tool returns a preview.",
      -  "type": "boolean"
      -}
    • addedInput schema / properties / confirmToken
      Added value: +{
      +  "description": "ONLY for the two-step confirmation fallback (a client without MCP elicitation). The confirmToken from this same tool's phase-1 \"confirmation-required\" response, passed back ONLY after the user has seen that preview and explicitly approved it in chat — never on the first call, never invented, never reused. Call again with the same arguments. Ignored when the client supports elicitation.",
      +  "type": "string"
      +}
  2. Changed1 schema field changedv2.0.0
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  3. Changed1 schema field changedv1.4.0
    • addedInput schema / properties / r2_key
      Added value: +{
      +  "description": "Unavailable on this server (media is written to local disk) — pass the file path via `path` instead.",
      +  "minLength": 1,
      +  "type": "string"
      +}
  4. First observedv1.2.0

TDQS

A4.6/5.0
Behavior4/5

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

Goes well beyond annotations (readOnlyHint=false, openWorldHint=true, destructiveHint=false) by disclosing the ~48h expiry, the no-bytes-in-context property, and the two-phase local-path confirmation flow with confirmToken. Minor gap: it doesn't say whether re-uploading the same file is idempotent or what happens to the old file_uri after expiry.

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 action and return value, then constraints, then the confirmation edge case. The keyword list is mild retrieval stuffing but arguably intentional; total length is justified by the two-parameter-mode and confirmation complexity.

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?

No output schema, yet the description gives the exact return shape (`file_uri` as `files/<id>`), the expiry, and the confirmation protocol. For a mutation tool with confirm gating and no output schema, nothing an agent needs to invoke it correctly is missing.

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 baseline is 3, but the description adds genuinely new semantics the schema does not encode: 'Provide exactly one of `url`, `data_base64`, or `path`' (no oneOf in the schema) and that path is confirmation-gated. It does not explain mime_type/display_name beyond the schema, which is fine.

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 (upload a file to the Gemini Files API) plus the concrete payoff (a reusable `file_uri` of the form `files/<id>`), and enumerates accepted media types. It is clearly distinguishable from siblings like gemini_delete_file, gemini_list_files and the generation tools.

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?

Explicitly routes the agent: 'Use this instead of pasting base64 into a tool call', names the alternative pattern and the reason (no image bytes in conversation), and states the reuse window until ~48h expiry. When/when-not is unambiguous.

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