Skip to main content
Glama

Upload media

wp_upload_media
Destructive

Upload base64-encoded JPEG, PNG, GIF, WebP, or PDF files to the WordPress media library, attach them to a post, and return the new attachment ID and public URL.

Instructions

Upload a JPEG, PNG, GIF, WebP or PDF file sent as base64 content and add it to the media library. WordPress checks the file as for any upload and creates the image sizes; the file is public under its URL afterwards, and each call adds a new file. The base64 text is limited to 8 MB, so the file to about 6 MB (less where the site sets a lower limit). Returns {uploaded: true, id, url}. Needs upload_files, and the right to edit post_id when the file is attached to it. A file already on the web is added with wp_upload_media_from_url.

Input Schema

NameRequiredDescriptionDefault
altNoAlternative text for an image, stored as plain text.
titleNoTitle of the new attachment.
contentYesBase64-encoded file bytes (JPEG, PNG, GIF, WebP or PDF); a data: URI prefix is accepted.
post_idNoId of a post to attach the file to; needs the right to edit that post. Default: attached to no post.
filenameYesFile name with extension, e.g. "photo.jpg".

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv4.7.0

TDQS

A4.6/5.0
Behavior5/5

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

Goes well beyond the annotations by disclosing the 8 MB base64 cap (~6 MB file, lower per site), that the file becomes publicly reachable at its URL, that every call creates a new file (matching idempotentHint=false and destructiveHint=true), that image sizes are generated, and the required upload_files capability plus edit rights on post_id. Also states the return shape {uploaded: true, id, url}.

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 action and accepted formats, followed by behavior, limits, return value, and the alternative — a sensible order with no filler. Two sentences are slightly garbled ("checks the file as for any upload", "so the file to about 6 MB"), which costs a point on polish rather than substance.

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?

For a 5-parameter mutation tool with no output schema, the description covers the input format, size ceiling, side effects, permissions, return shape, and the sibling alternative. Nothing material an agent needs to call 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 a 3 is the floor. The description adds meaning the schema lacks: the 8 MB base64 ceiling, the accepted data: URI prefix context, and the permission dependency on post_id — practical constraints an agent needs before constructing content.

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 and resource ("Upload a JPEG, PNG, GIF, WebP or PDF file sent as base64 content and add it to the media library") and names the sibling it is not (wp_upload_media_from_url) for the URL-based case. An agent can distinguish it from wp_update_media and wp_list_media without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly routes the agent: files already on the web go to wp_upload_media_from_url, implying this tool is for local base64 bytes. It does not address when to prefer this over updating an existing attachment (wp_update_media), so it stops just short of full when/when-not coverage.

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

Deploy Server

Other Tools