Skip to main content
Glama
gaupoit

WordPress MCP Server

by gaupoit

wp_get_media

Retrieve media items from WordPress library by type and quantity to access images, videos, audio, or documents for content management.

Instructions

Get media items from WordPress media library.

Args:
    per_page: Number of items to return (1-100). Default is 10.
    media_type: Filter by type - 'image', 'video', 'audio', or 'application'.

Returns:
    List of media items with id, title, url, mime_type, and alt_text.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
per_pageNo
media_typeNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function for 'wp_get_media'. Decorated with @mcp.tool() for registration. Calls WordPressClient.get_media() to fetch and return media items.
    @mcp.tool()
    def wp_get_media(
        per_page: int = 10,
        media_type: str | None = None,
    ) -> list[dict]:
        """Get media items from WordPress media library.
    
        Args:
            per_page: Number of items to return (1-100). Default is 10.
            media_type: Filter by type - 'image', 'video', 'audio', or 'application'.
    
        Returns:
            List of media items with id, title, url, mime_type, and alt_text.
        """
        client = get_client()
        return client.get_media(per_page=per_page, media_type=media_type)
  • Supporting method in WordPressClient that makes the REST API GET request to the /media endpoint, processes the response, and returns formatted list of media items.
    def get_media(
        self,
        per_page: int = 10,
        media_type: str | None = None,
    ) -> list[dict]:
        """Get media items from WordPress."""
        params = {"per_page": per_page}
    
        if media_type:
            params["media_type"] = media_type
    
        media = self._get("media", params)
    
        return [
            {
                "id": m["id"],
                "title": m["title"]["rendered"],
                "url": m["source_url"],
                "mime_type": m["mime_type"],
                "alt_text": m.get("alt_text", ""),
            }
            for m in media
        ]
Behavior3/5

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

With no annotations provided, the description carries the full burden. It implies a read-only operation ('Get') and describes the return format, which is helpful. However, it lacks details on permissions, rate limits, pagination beyond per_page, or error handling, leaving 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 well-structured and front-loaded with the purpose, followed by clear sections for Args and Returns. Every sentence adds value without redundancy, making it efficient and easy to parse.

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

Completeness4/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 (2 parameters, no annotations, but has output schema), the description is fairly complete. It covers the purpose, parameters, and return values, though it could improve by adding usage guidelines or more behavioral context to be fully comprehensive.

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?

The description adds significant meaning beyond the input schema, which has 0% description coverage. It explains per_page as 'Number of items to return (1-100)' with a default, and media_type as a filter with specific values ('image', 'video', 'audio', 'application'), compensating well for the schema's lack of details.

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 'Get' and resource 'media items from WordPress media library', which is specific and unambiguous. It distinguishes from siblings like wp_get_posts or wp_get_pages by focusing on media items, though it doesn't explicitly contrast them.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives. It doesn't mention sibling tools like wp_get_posts (which might include media) or wp_site_info (which could provide media-related info), nor does it specify prerequisites or contexts for usage.

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/gaupoit/wordpress-mcp'

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