Skip to main content
Glama

wp_list_pages

Retrieve and filter WordPress pages from a configured site using parameters like search terms, status, and pagination for site management.

Instructions

Lists pages from a WordPress site, with filters.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
per_pageNoNumber of items to return per page (max 100).
searchNoLimit results to those matching a search term.
statusNoFilter by page status.

Implementation Reference

  • The handler function that implements the core logic of the wp_list_pages tool. It queries the WordPress client for pages using provided parameters, formats a list of pages with IDs, titles, status, and links, or returns a no-pages message on empty results.
    public async handleListPages(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const queryParams = params as unknown as PageQueryParams; try { const pages = await client.getPages(queryParams); if (pages.length === 0) { return "No pages found matching the criteria."; } const content = `Found ${pages.length} pages:\n\n` + pages.map((p) => `- ID ${p.id}: **${p.title.rendered}** (${p.status})\n Link: ${p.link}`).join("\n"); return content; } catch (_error) { throw new Error(`Failed to list pages: ${getErrorMessage(_error)}`); } }
  • The tool registration within PageTools.getTools(), defining the name, description, input parameters schema (per_page, search, status), and binding to the handleListPages handler.
    { name: "wp_list_pages", description: "Lists pages from a WordPress site, with filters.", parameters: [ { name: "per_page", type: "number", description: "Number of items to return per page (max 100).", }, { name: "search", type: "string", description: "Limit results to those matching a search term.", }, { name: "status", type: "string", description: "Filter by page status.", enum: ["publish", "future", "draft", "pending", "private"], }, ], handler: this.handleListPages.bind(this), },
  • Generic registration loop in ToolRegistry.registerAllTools() that instantiates PageTools (imported via * as Tools from '@/tools/index.js'), calls getTools() to retrieve wp_list_pages definition, and registers it with the MCP server via registerTool().
    Object.values(Tools).forEach((ToolClass) => { let toolInstance: { getTools(): unknown[] }; // Cache and Performance tools need the clients map if (ToolClass.name === "CacheTools" || ToolClass.name === "PerformanceTools") { toolInstance = new ToolClass(this.wordpressClients); } else { toolInstance = new (ToolClass as new () => { getTools(): unknown[] })(); } const tools = toolInstance.getTools(); tools.forEach((tool: unknown) => { this.registerTool(tool as ToolDefinition); }); });

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