Skip to main content
Glama
gaupoit

WordPress MCP Server

by gaupoit

wp_get_post

Retrieve a WordPress post by its ID to access the full content, title, excerpt, status, date, slug, and link for content management or analysis.

Instructions

Get a single post by ID with full content.

Args:
    post_id: The ID of the post to retrieve.

Returns:
    Post with id, title, content (raw), excerpt, status, date, slug, and link.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
post_idYes

Implementation Reference

  • The handler function for the 'wp_get_post' tool, registered via @mcp.tool() decorator. It retrieves the WordPressClient instance and calls its get_post method to fetch the post data.
    @mcp.tool()
    def wp_get_post(post_id: int) -> dict:
        """Get a single post by ID with full content.
    
        Args:
            post_id: The ID of the post to retrieve.
    
        Returns:
            Post with id, title, content (raw), excerpt, status, date, slug, and link.
        """
        client = get_client()
        return client.get_post(post_id)
  • Supporting method in WordPressClient that performs the actual API call to retrieve a single post by ID from the WordPress REST API and formats the response.
    def get_post(self, post_id: int) -> dict:
        """Get a single post by ID with full content."""
        post = self._get(f"posts/{post_id}", params={"context": "edit"}, require_auth=True)
    
        return {
            "id": post["id"],
            "title": post["title"]["raw"] if isinstance(post["title"], dict) else post["title"],
            "content": post["content"]["raw"] if isinstance(post["content"], dict) else post["content"],
            "excerpt": post["excerpt"]["raw"] if isinstance(post["excerpt"], dict) else post["excerpt"],
            "status": post["status"],
            "date": post["date"],
            "slug": post["slug"],
            "link": post.get("link", ""),
        }

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