Skip to main content
Glama

wp_list_media

Retrieve and filter media items from a WordPress site, enabling users to search, paginate results, and specify media types for efficient content management.

Instructions

Lists media items from a WordPress site, with filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
per_pageNoNumber of items to return per page (max 100).
searchNoLimit results to those matching a search term.
media_typeNoLimit results to a specific media type.

Implementation Reference

  • The handler function that implements the core logic of the wp_list_media tool. It queries the WordPress client for media items based on provided parameters, handles empty results, formats a markdown list of media items with IDs, titles, MIME types, and source URLs, and includes error handling.
    public async handleListMedia(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const queryParams = params as MediaQueryParams;
      try {
        const media = await client.getMedia(queryParams);
        if (media.length === 0) {
          return "No media items found matching the criteria.";
        }
        const content =
          `Found ${media.length} media items:\n\n` +
          media.map((m) => `- ID ${m.id}: **${m.title.rendered}** (${m.mime_type})\n  Link: ${m.source_url}`).join("\n");
        return content;
      } catch (_error) {
        throw new Error(`Failed to list media: ${getErrorMessage(_error)}`);
      }
    }
  • The registration of the wp_list_media tool within the MediaTools.getTools() method, defining the tool name, description, input parameters schema, and binding the handler function. This object is returned by getTools() and registered dynamically by ToolRegistry.
    {
      name: "wp_list_media",
      description: "Lists media items from a WordPress site, with filters.",
      parameters: [
        {
          name: "per_page",
          type: "number",
          description: "Number of items to return per page (max 100).",
        },
        {
          name: "search",
          type: "string",
          description: "Limit results to those matching a search term.",
        },
        {
          name: "media_type",
          type: "string",
          description: "Limit results to a specific media type.",
          enum: ["image", "video", "audio", "application"],
        },
      ],
      handler: this.handleListMedia.bind(this),
    },
  • The input schema definition for the wp_list_media tool parameters: per_page (number), search (string), media_type (string with enum). Used for validation in the MCP server.
    parameters: [
      {
        name: "per_page",
        type: "number",
        description: "Number of items to return per page (max 100).",
      },
      {
        name: "search",
        type: "string",
        description: "Limit results to those matching a search term.",
      },
      {
        name: "media_type",
        type: "string",
        description: "Limit results to a specific media type.",
        enum: ["image", "video", "audio", "application"],
      },
    ],
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 mentions filtering but doesn't specify pagination behavior (e.g., default page, total count), rate limits, authentication requirements, or error handling. For a list operation with potential complexity, this leaves significant gaps in understanding how the tool behaves beyond basic functionality.

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, efficient sentence that front-loads the core purpose ('Lists media items from a WordPress site') and adds a key feature ('with filters') without any wasted words. It's appropriately sized for a straightforward list tool, 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 moderate complexity (list operation with 4 optional parameters) and lack of annotations and output schema, the description is minimally adequate. It covers the basic purpose but misses details like return format (e.g., array of objects, pagination metadata), error cases, or performance considerations, which would be helpful for an agent to use it effectively.

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?

Schema description coverage is 100%, so the schema fully documents all four parameters (site, per_page, search, media_type). The description adds no additional meaning beyond 'with filters,' which is already implied by the parameter names. This meets the baseline of 3, as the schema does the heavy lifting, but the description doesn't enhance parameter understanding.

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 verb ('Lists') and resource ('media items from a WordPress site'), making the purpose unambiguous. It distinguishes itself from sibling tools like wp_get_media (which likely retrieves a single item) and wp_delete_media by focusing on listing with filtering. However, it doesn't explicitly differentiate from wp_search_site, which might overlap in search functionality.

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 through 'with filters,' suggesting it's for retrieving multiple media items with optional filtering, but provides no explicit guidance on when to use this versus alternatives like wp_get_media (for single items) or wp_search_site (for broader site searches). No when-not-to-use scenarios or prerequisites are mentioned, leaving usage context partially inferred.

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