Skip to main content
Glama

create_document_upload_url

Destructive

Step 1 of the recommended flow for a LOCAL file when you (the calling agent) have shell/code-execution access (Bash, a script, curl, etc.): reserves a document record + a one-time signed upload URL, so the actual file bytes travel via a plain HTTP PUT from your shell — never through your own context/output tokens, regardless of file size.

Required: filename. Optional: mime_type, doc_type (default 'file'), title (default filename), description, amount, currency, status, occurred_at.

WHICH OF THE TWO WAYS: pass entity ('lead'|'contact'|'account'|'campaign') AND entity_id for a CRM document — an offer for a lead, an invoice for an account. Pass NEITHER for anything else: a screenshot for a SupportAIze ticket, a spreadsheet you are handing to another system, a file that has no CRM record. Both or neither; one alone is rejected, because a half-filed document appears in no list at all. Find the unfiled ones again with list_documents({unfiled:true}), and file one later with update_document({document_id, entity, entity_id}) once you know where it belongs.

THE STABLE REFERENCE IS THE document_id, not a URL. get_document_link mints a fresh signed URL on demand (default 1 h, max 24 h) and checks the tenant every time. So hand another system the document_id, or have it fetch the bytes once at attach time — never store the signed URL, it expires and then points at nothing while looking like a working attachment.

Optional provenance, for anything imported from somewhere else: source (e.g. 'beeper'), external_id (the id at that source) and source_meta (an object: network, chat_id, chat_title, sender, sender_id, sent_at, message_id — never credentials). Passing source + external_id also makes the call IDEMPOTENT: a second call for the same one returns the document already stored, with duplicate:true and NO upload_url, instead of a second record. That is the only place this can be enforced, because only the database sees both attempts.

Returns { document_id, upload_url, storage_path } — or { document_id, duplicate: true } when it was already stored. Next: from your shell, PUT the raw file to upload_url — e.g. curl -T /path/to/file "$upload_url". No CallPilotAI credential is needed for that PUT; the URL is self-authorizing and expires in ~2 hours. Then call finalize_document_upload with document_id to confirm the upload landed, backfill its size/type, and run AI analysis. If you never complete the PUT, delete_document the reserved document_id to avoid leaving an empty record behind.

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": {
      "filename": "<filename>"
    },
    "name": "create_document_upload_url"
  }
}

Input Schema

NameRequiredDescriptionDefault
titleNoTitle of the document
amountNoAmount
entityNoRecord type for a CRM document: lead, contact, account or campaign; pass with entity_id or omit both
sourceNoSource system the file was imported from, e.g. 'beeper'; with external_id makes the call idempotent
statusNoInitial status
currencyNoCurrency code (ISO 4217, e.g. EUR)
doc_typeNoType of document (default 'file')
filenameYesFile name
entity_idNoID of the record
mime_typeNoMIME type of the file
descriptionNoDescription of the document
external_idNoID of the external
occurred_atNoWhen it happened (ISO 8601)
source_metaNoProvenance details (network, chat_id, chat_title, sender, sender_id, sent_at, message_id), never credentials

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed14 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 (default 'file')"
    • addedInput schema / properties / entity / description
      Added value: +"Record type for a CRM document: lead, contact, account or campaign; pass with entity_id or omit both"
    • addedInput schema / properties / entity_id / description
      Added value: +"ID of the record"
    • addedInput schema / properties / external_id / description
      Added value: +"ID of the external"
    • addedInput schema / properties / filename / description
      Added value: +"File name"
    • 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 / source / description
      Added value: +"Source system the file was imported from, e.g. 'beeper'; with external_id makes the call idempotent"
    • addedInput schema / properties / source_meta / description
      Added value: +"Provenance details (network, chat_id, chat_title, sender, sender_id, sent_at, message_id), never credentials"
    • 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.5/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true, readOnlyHint=false and idempotentHint=false, and the description adds real context beyond that: the self-authorizing URL expires in ~2 hours, no credential is required for the PUT, and an abandoned reservation leaves an empty record that should be cleaned up with delete_document. However, it also asserts a conditional idempotency (source + external_id returns duplicate:true) that sits in tension with the structured idempotentHint=false, and it never states the permission requirements for reserving a record, so the disclosure is strong but not fully reconciled with the annotations.

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 step framing and the one-line purpose before the parameter and branching detail, and the paragraph headers (WHICH OF THE TWO WAYS, THE STABLE REFERENCE, optional provenance, Returns) make it skimmable. It is long for a tool description and the document_id-vs-URL rationale runs a couple of sentences past the minimum, but almost every line carries operational weight.

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?

Covers the entire lifecycle an agent needs: what is reserved, which parameters branch the behavior, the exact return shape for both the fresh and duplicate cases, the follow-up PUT example, the required finalize_document_upload call, and the cleanup path if the PUT never happens. With 14 parameters, a nested source_meta object and no output schema, nothing material is left for the agent to infer.

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

Parameters5/5

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

Schema coverage is already 100%, yet the description still adds meaning the schema cannot express: title defaults to filename, doc_type defaults to 'file', entity and entity_id must be supplied as a pair or not at all, and source + external_id together are what turn on the idempotent path (returning the existing document without upload_url). It also constrains source_meta contents ('never credentials').

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 and the exact scope: 'reserves a document record + a one-time signed upload URL' for a LOCAL file when the agent has shell/code-execution access. It distinguishes itself from the sibling upload_document by making clear the bytes travel via a plain HTTP PUT from the shell rather than through context tokens.

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 frames the tool as step 1 of a named flow and rules out the alternative path (uploading bytes through the agent), then spells out the entity/entity_id rule with a rationale for why one-alone is rejected, and routes to get_document_link, update_document, list_documents({unfiled:true}), finalize_document_upload and delete_document for each follow-on situation.

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.