Files and post versions
Upload files from an agent and publish a new version of a post through the MCP server.
Upload files from an agent
Use prepare_media_upload with destination, fileName, and the exact fileSize in bytes. Content destinations are post, newPost, task, comment, taskComment, newTaskComment, chatMessage, newChatMessage, canvas, and doc. Image settings use avatar, workspaceLogo, projectHeader, projectIcon, portalLogo, portalBanner, and customReaction. Transfer the local file to the returned URL with the indicated protocol, then call complete_media_upload with uploadToken and any returned part ETags. The same token can be retried after a connection failure. get_media_upload reports whether placement has finished.
{
"destination": {"type": "doc", "id": "page-id", "afterBlockId": "block-id"},
"fileName": "diagram.png",
"fileSize": 245760
}Doc uploads create native inline media blocks. Omit afterBlockId to append. Chat includes team messages in portal discussions. Canvas accepts x, y, width, height, and frameId. Uploads require media:write; Docs, Chat, and Canvas also require docs:write, chat:write, and canvas:write respectively. Images, videos, models, and ordinary files follow the app's format and size limits.
The MCP tools exchange metadata and upload URLs. Your agent needs access to the file and an HTTP transfer tool, or a terminal with the CLI. A hosted chat client without those capabilities cannot transfer local files. Keep bytes out of tool arguments and use the CLI when available:
pf media upload diagram.png --doc page-id --resume-state ./upload.jsonTo create a post with files, prepare each upload with destination type newPost and the project ID, transfer the bytes, then pass the uploadToken and part ETags in uploads to create_post. The post appears with its files already attached.
To attach a file to a new task comment, prepare the upload with destination type newTaskComment and the task ID, transfer the bytes, then pass the uploadToken and part ETags in uploads to create_task_comment instead of calling complete_media_upload. Each token works once, so pass an idempotencyKey to make a retry return the comment.
To send a chat message with files, prepare each upload with destination type newChatMessage and the room ID, transfer the bytes, then pass the uploadToken and part ETags in uploads to send_chat_message. The message can have no text when it carries files.
See the Files API for transfer protocols and retry behavior.
Publish post versions
list_post_versions returns a post's versions, newest first, with change notes, authors, and media. get_post_version reads one version by versionId or number and includes its content. publish_post_version publishes a new version of a post you wrote. Title and content carry over when omitted, and mediaIds lists the current media to keep, in order.
To add a file to the new version, call prepare_media_upload with destination type post and the post ID, transfer the bytes, then pass the uploadToken and part ETags in uploads instead of calling complete_media_upload. Reading versions needs posts:read. Publishing needs posts:write, plus media:write when it includes uploads.
To replace a current file, add replacesMediaId, that file's media ID, to its upload item. The new file takes the old file's position, and the ID must not also be in mediaIds.
{
"name": "publish_post_version",
"arguments": {
"postId": "post-id",
"changeNote": "Tightened the hero crop",
"mediaIds": ["media-id"],
"uploads": [
{"uploadToken": "token", "parts": [{"partNumber": 1, "etag": "etag"}]}
],
"idempotencyKey": "hero-v3"
}
}