Skip to main content
Glama
gaupoit

WordPress MCP Server

by gaupoit

wp_get_posts

Retrieve WordPress posts by status, quantity, or search term to access content data like titles, excerpts, and links.

Instructions

Get posts from WordPress.

Args:
    status: Post status filter - 'publish', 'draft', or 'all'. Default is 'publish'.
    per_page: Number of posts to return (1-100). Default is 10.
    search: Search term to filter posts by title/content.

Returns:
    List of posts with id, title, status, date, slug, excerpt, and link.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusNopublish
per_pageNo
searchNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'wp_get_posts' tool. It is registered via the @mcp.tool() decorator. Defines input parameters with type hints and docstring serving as schema. Delegates to WordPressClient.get_posts().
    @mcp.tool()
    def wp_get_posts(
        status: str = "publish",
        per_page: int = 10,
        search: str | None = None,
    ) -> list[dict]:
        """Get posts from WordPress.
    
        Args:
            status: Post status filter - 'publish', 'draft', or 'all'. Default is 'publish'.
            per_page: Number of posts to return (1-100). Default is 10.
            search: Search term to filter posts by title/content.
    
        Returns:
            List of posts with id, title, status, date, slug, excerpt, and link.
        """
        client = get_client()
        return client.get_posts(status=status, per_page=per_page, search=search)
  • Supporting method in WordPressClient that implements the core logic: constructs API parameters, handles authentication requirements, calls the WordPress REST API endpoint /posts, and formats the response into a list of simplified post dictionaries.
    def get_posts(
        self,
        status: str = "publish",
        per_page: int = 10,
        search: str | None = None,
    ) -> list[dict]:
        """Get posts from WordPress."""
        params = {"per_page": per_page}
    
        if status != "all":
            params["status"] = status
    
        if search:
            params["search"] = search
    
        # Status other than 'publish' requires auth
        require_auth = status != "publish"
    
        posts = self._get("posts", params, require_auth)
    
        return [
            {
                "id": p["id"],
                "title": p["title"]["rendered"],
                "status": p["status"],
                "date": p["date"],
                "slug": p["slug"],
                "excerpt": p["excerpt"]["rendered"][:200] if p.get("excerpt") else "",
                "link": p["link"],
            }
            for p in posts
        ]
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses that this is a read operation ('Get'), describes the return format, and mentions default values, which adds useful context. However, it lacks information about authentication needs, rate limits, pagination behavior beyond per_page, or error handling, leaving behavioral gaps for a tool with filtering capabilities.

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 efficiently structured with a clear purpose statement followed by organized Args and Returns sections. Every sentence adds value: the opening establishes context, parameter explanations are necessary given schema gaps, and the return format disclosure is essential with no output schema in the context signals. No wasted words.

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 3 parameters with 0% schema coverage and no annotations, the description does well by documenting all parameters and the return format. However, as a read operation with filtering capabilities, it could benefit from mentioning authentication requirements or pagination limits. The context signals indicate an output schema exists, so the return format explanation is somewhat redundant but still helpful for clarity.

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 schema has 0% description coverage, so the description must compensate fully. It successfully adds meaning for all 3 parameters: explaining what 'status' filters (with enum-like values), what 'per_page' controls (with range context), and what 'search' filters by (title/content). This goes beyond the bare schema to provide practical usage context, though it doesn't specify exact search behavior (e.g., partial matches).

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 'posts from WordPress', making the purpose immediately understandable. It distinguishes from siblings like wp_create_post (create) and wp_delete_post (delete) by focusing on retrieval, though it doesn't explicitly contrast with wp_get_post (singular) or wp_get_pages (different resource).

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 for retrieving posts with filtering options, but provides no explicit guidance on when to use this vs. alternatives like wp_get_post (for single posts) or wp_get_pages (for pages). The context of filtering by status/search suggests when it might be useful, but lacks clear when-not-to-use statements or prerequisite information.

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