upload_file
Uploads a local file into an Overleaf project folder, storing it as a text document or binary by extension and UTF-8 validity. Replacing existing files requires overwrite or expectedHash.
Instructions
Upload a local file into a project folder. Overleaf decides whether it becomes a text document or a binary file, by extension and UTF-8 validity. Something already at the path is replaced only when asked for, and otherwise nothing is sent. Replacing a binary needs overwrite: true, or expectedHash equal to its hash from get_project_tree; without either it is CONFIRMATION_MISMATCH, and a different hash is REMOTE_DRIFT. expectedHash is checked just before the upload, not atomically with it. Replacing a text document is a blind write with no revision check, so it needs uncheckedDocumentReplace: true, else INVALID_ARGUMENT: prefer read_file then write_file with localPath, and pass uncheckedDocumentReplace only when nobody else is editing it. overwrite: false refuses any replacement with CONFIRMATION_MISMATCH. A replaced text document keeps its entity ID; a replaced binary file may get a new one. writeMode in the result is tracked when Overleaf records a document replacement as tracked changes, because track changes is on for this account.
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": {
"projectId": "<projectId>",
"localPath": "<localPath>"
},
"name": "upload_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| localPath | Yes | ||
| overwrite | No | true allows replacing a binary file at the path; false refuses to replace anything; omitted, replacing a binary needs expectedHash | |
| projectId | Yes | Overleaf project ID | |
| expectedHash | No | The hash get_project_tree reported for the binary file being replaced; a different one is REMOTE_DRIFT | |
| destinationName | No | Name to store the file under; defaults to the local file name | |
| destinationFolderPath | No | ||
| uncheckedDocumentReplace | No | Allow replacing a text document, a blind write with no revision check; prefer write_file with localPath when a collaborator may be editing |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hash | No | ||
| path | Yes | ||
| entityId | No | ||
| replaced | Yes | ||
| writeMode | Yes | ||
| entityType | No | ||
| trackChangesActive | Yes |