Skip to main content
Glama

wp_get_media

Retrieve a specific media file from a WordPress site by providing its unique ID to access or manage the item directly.

Instructions

Retrieves a single media item by its ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe unique identifier for the media item.

Implementation Reference

  • The handler function that implements the core logic of the wp_get_media tool. It takes a WordPressClient and parameters, extracts the media ID, fetches the media item details via client.getMediaItem(id), formats a markdown-style response string with key metadata (title, URL, type, date, alt text, caption), and handles errors by throwing a descriptive message.
    public async handleGetMedia(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const { id } = params as { id: number };
      try {
        const media = await client.getMediaItem(id);
        const content =
          `**Media Details (ID: ${media.id})**\n\n` +
          `- **Title:** ${media.title.rendered}\n` +
          `- **URL:** ${media.source_url}\n` +
          `- **Type:** ${media.media_type} (${media.mime_type})\n` +
          `- **Date:** ${new Date(media.date).toLocaleString()}\n` +
          (media.alt_text ? `- **Alt Text:** ${media.alt_text}\n` : "") +
          (media.caption.rendered ? `- **Caption:** ${media.caption.rendered}\n` : "");
        return content;
      } catch (_error) {
        throw new Error(`Failed to get media item: ${getErrorMessage(_error)}`);
      }
    }
  • The registration of the wp_get_media tool within the MediaTools.getTools() method's return array. It specifies the tool's name, description, input schema (parameters), and binds the handler function for execution.
    {
      name: "wp_get_media",
      description: "Retrieves a single media item by its ID.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The unique identifier for the media item.",
        },
      ],
      handler: this.handleGetMedia.bind(this),
    },
  • The input schema definition for the wp_get_media tool, specifying a single required 'id' parameter of type number with description.
    parameters: [
      {
        name: "id",
        type: "number",
        required: true,
        description: "The unique identifier for the media item.",
      },
    ],
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves data (implying read-only), but doesn't mention authentication requirements, rate limits, error handling, or what happens if the ID doesn't exist. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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?

The description is a single, clear sentence that efficiently conveys the core purpose without unnecessary words. It's front-loaded with the essential information and has zero wasted content, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (simple retrieval), high schema coverage, and lack of output schema, the description is minimally adequate. However, it doesn't address behavioral aspects like authentication or error handling, which would be helpful for a tool with no annotations. It meets basic needs but leaves room for improvement.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with both parameters ('site' and 'id') well-documented in the schema. The description doesn't add any meaningful parameter semantics beyond what's already in the schema (e.g., it doesn't clarify ID format or site selection logic). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('retrieves') and resource ('a single media item by its ID'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'wp_list_media' (which lists multiple items) or 'wp_get_post' (which retrieves a different resource type), missing full sibling differentiation.

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

Usage Guidelines3/5

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

The description implies usage context (when you need a specific media item by ID) but doesn't provide explicit guidance on when to use this versus alternatives like 'wp_list_media' for browsing or 'wp_update_media' for modifications. No exclusions or prerequisites are mentioned, leaving usage somewhat open to interpretation.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/docdyhr/mcp-wordpress'

If you have feedback or need assistance with the MCP directory API, please join our Discord server