Skip to main content
Glama

Read a media file

wp_get_media
Read-onlyIdempotent

Retrieve a single WordPress media library attachment by ID to get its URL, title, MIME type, alt text, caption, and metadata, including image dimensions and generated sizes.

Instructions

Get one file of the media library (attachment) by id. Returns {id, title, mime, url, alt, caption, metadata}; metadata is WordPress' attachment metadata (for an image: width, height, file and the generated sizes). The caption of a password-protected file is empty for an account that may not edit it. An id that is not a media file (a post, say) returns a not-found error: posts and pages are read by wp_get_post, and wp_list_media lists the media with their ids. Needs the right to read the file.

Input Schema

NameRequiredDescriptionDefault
idYesAttachment id, as wp_list_media returns it.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv4.7.0

TDQS

A4.9/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive), and the description adds real behavioral context on top: the exact return shape, what attachment metadata contains, an edge case (caption empty for password-protected files on accounts without edit rights), and a permission requirement ('Needs the right to read the file'). The distinct not-found failure mode for non-media ids is also disclosed.

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

Conciseness5/5

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

Four sentences, front-loaded with the action and return shape before the edge cases and sibling routing. Every clause carries actionable information; nothing is repeated from the schema or annotations.

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?

There is no output schema, yet the description enumerates the return contract and explains the metadata sub-object, plus error and permission behavior. Nothing an agent needs in order to call this 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?

Only one parameter, and the schema already documents it at 100% coverage ('Attachment id, as wp_list_media returns it'), so baseline is 3. The description earns a bump by constraining the id's domain — it must reference an actual media attachment, otherwise a not-found error results.

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 ('Get one file of the media library (attachment) by id') and immediately enumerates the returned fields. It explicitly separates itself from siblings: posts/pages go to wp_get_post and collections go to wp_list_media.

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 both the when-not ('An id that is not a media file ... posts and pages are read by wp_get_post') and the alternative for listing ('wp_list_media lists the media with their ids'). An agent can route correctly without opening any other schema.

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