Skip to main content
Glama

wp_get_page

Retrieve a WordPress page by its ID to view or edit content, with optional full HTML content inclusion for detailed management.

Instructions

Retrieves a single page by its ID, optionally including full content for editing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe unique identifier for the page.
include_contentNoIf true, includes the full HTML content of the page. Default: false

Implementation Reference

  • The handler function that executes the wp_get_page tool: retrieves the page by ID using WordPressClient, formats details (title, status, link, date, optional content), and returns as formatted string.
    public async handleGetPage(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const { id, include_content = false } = params as { id: number; include_content?: boolean };
      try {
        const page = await client.getPage(id);
        let content =
          `**Page Details (ID: ${page.id})**\n\n` +
          `- **Title:** ${page.title.rendered}\n` +
          `- **Status:** ${page.status}\n` +
          `- **Link:** ${page.link}\n` +
          `- **Date:** ${new Date(page.date).toLocaleString()}`;
    
        if (include_content) {
          content += `\n\n**Content:**\n\n` + `${page.content.rendered || "(empty)"}`;
        }
    
        return content;
      } catch (_error) {
        throw new Error(`Failed to get page: ${getErrorMessage(_error)}`);
      }
    }
  • Registers the 'wp_get_page' tool in the PageTools.getTools() array, defining its name, description, input parameters schema, and binding the handler function.
    {
      name: "wp_get_page",
      description: "Retrieves a single page by its ID, optionally including full content for editing.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The unique identifier for the page.",
        },
        {
          name: "include_content",
          type: "boolean",
          description: "If true, includes the full HTML content of the page. Default: false",
        },
      ],
      handler: this.handleGetPage.bind(this),
    },

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