Skip to main content
Glama

Replace a document with a new version

replace_document
Destructive

Changes data: replaces one document with a new file (a PDF, a JPEG, PNG or TIFF image, or an Excel or CSV spreadsheet, 50 MB at most), as the person who connected this app, and records it in the organization's audit log. The old document is kept as an older version that restore_document can bring back, but it stops counting: the new file is read (an AI extraction) and what it says takes the old one's place, so the data imported from the old one is replaced. Replacing a bill of lading or other transport document also lets the new one change the shipment's B/L number, which can change which shipment is tracked and where. Use it only when the user asks to replace or correct a document, and say which document and which file before calling. Give the file in exactly one way. In ChatGPT, pass the attached file as file. Otherwise give file_url, a public HTTPS link that Trackberry downloads once with no credentials. A link that needs a sign-in cannot be fetched (Microsoft 365, SharePoint and OneDrive links, Google Drive and Docs links that ask for a login, and similar share pages) and is refused with file_url_needs_sign_in; a direct download link that is public works. file_base64 with filename is a last resort for small files, 256 KB at most. When you have no public URL and the file is not small, or you only hold such a sign-in link or an attachment you cannot pass (a Claude.ai or Microsoft Copilot chat attachment, say), call request_upload_link instead (with replace_document_id set to this document) and give the user that link; pass replace_document_id with this document's id and the file the user chooses replaces it, exactly as this tool would. Only a current document can be replaced. Sending the same file again for a document it already replaced comes back as that replacement, with created false; a different file is a second replacement. Answers with the new document (replaces names the old one).

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": {
      "document_id": "<document_id>"
    },
    "name": "replace_document"
  }
}

Input Schema

NameRequiredDescriptionDefault
fileNoChatGPT's attached-file object. Pass the file the user attached as it is given to you.
file_urlNoA public HTTPS link to the file. Trackberry downloads it without credentials, so a link that needs a sign-in (SharePoint, OneDrive, Google Drive) does not work: use request_upload_link for those.
filenameNoThe file's name with its extension, such as "invoice.pdf". Required with file_base64; optional with file_url.
document_idYesA document id such as "doc_45", as returned by list_documents.
file_base64NoThe file's bytes, base64 encoded, 256 KB at most when decoded. A last resort for small files: it costs you the whole file as output.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / file_url / description
      Previous value: -"A public HTTPS link to the file. Trackberry downloads it without credentials, so a link that needs a login does not work."New value: +"A public HTTPS link to the file. Trackberry downloads it without credentials, so a link that needs a sign-in (SharePoint, OneDrive, Google Drive) does not work: use request_upload_link for those."
  2. Added

TDQS

A4.7/5.0
Behavior5/5

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

Annotations only flag destructive/openWorld/non-idempotent; the description goes much further by disclosing the audit-log record, that the old file is retained as a restorable version, that AI extraction re-imports data and supersedes the old import, and that replacing a transport document can shift the tracked shipment via the B/L number. It also states acting identity ("as the person who connected this app") and the dedup behavior (same file returns the prior replacement with created false), which the annotations cannot convey.

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

Conciseness3/5

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

Core behavior and the when-to-use rule are front-loaded, which is good, but the prose is dense and repetitive: the sign-in-link problem is explained twice (once for file_url, again in the request_upload_link paragraph), and lines like "a direct download link that is public works" restate the prior clause. The length is defensible for a destructive 5-parameter tool, yet tighter editing would preserve all the information.

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?

With no output schema, the description still closes the loop by stating the response shape ("Answers with the new document (`replaces` names the old one)") and the dedup return with created false. Combined with the versioning, audit, and fallback-path details, an agent has everything needed to invoke it correctly and explain the consequences to a user.

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 real constraints the schema does not: the fields are mutually exclusive ("Give the file in exactly one way"), the ChatGPT-only scope of `file`, the specific failure code file_url_needs_sign_in, and that file_base64 is capped at 256 KB. Some of this (public-URL requirements) duplicates the schema text, keeping it from a 5.

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?

Opens with a specific verb and resource — "replaces one document with a new file" — and immediately scopes the accepted file types and the 50 MB ceiling. It distinguishes itself from restore_document (which brings back the prior version) and request_upload_link (the fallback path), so an agent can route correctly without opening the schema.

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?

Gives an explicit trigger ("only when the user asks to replace or correct a document") plus a confirmation precondition (state which document and which file before calling). It names concrete alternatives and the conditions that select them: request_upload_link for sign-in links or unpasseable attachments, and restore_document for reverting. The "only a current document can be replaced" exclusion is also stated.

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