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

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
        ]

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