wpnav_list_posts
Retrieve and filter WordPress blog posts by status, search term, or pagination to view IDs, titles, statuses, and modification dates.
Instructions
List WordPress blog posts with optional filtering. Returns post ID, title, status, and last modified date.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination (default: 1) | |
| per_page | No | Number of posts to return (default: 10, max: 100) | |
| status | No | Filter by status (default: publish) | |
| search | No | Search term to filter posts by title or content |
Implementation Reference
- src/tools/content/index.ts:383-412 (registration)Registration of the wpnav_list_posts tool via toolRegistry.register. Includes the tool definition (name, description, input schema), the handler function that fetches posts from WP REST API /wp/v2/posts with pagination/filtering, processes summaries using utilities, and returns formatted response. This is the core implementation.toolRegistry.register({ definition: { name: 'wpnav_list_posts', description: 'List WordPress blog posts with optional filtering. Returns post ID, title, status, and last modified date.', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (default: 1)' }, per_page: { type: 'number', description: 'Number of posts to return (default: 10, max: 100)' }, status: { type: 'string', enum: ['publish', 'draft', 'private', 'any'], description: 'Filter by status (default: publish)' }, search: { type: 'string', description: 'Search term to filter posts by title or content' }, }, required: [], }, }, handler: async (args, context) => { const { page, per_page } = validatePagination(args); const status = args.status || 'publish'; const qs = buildQueryString({ page, per_page, status, search: args.search }); const posts = await context.wpRequest(`/wp/v2/posts?${qs}`); const summary = posts.map((p: any) => extractSummary(p, ['id', 'title.rendered', 'status', 'modified', 'link'])); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(summary, null, 2)) }], }; }, category: ToolCategory.CONTENT, });
- src/tools.ts:176-204 (schema)Static tool schema definition for wpnav_list_posts exported in tools array, likely used for MCP tool discovery or client-side validation. Matches the schema in the dynamic registration.name: 'wpnav_list_posts', description: 'List WordPress blog posts with optional filtering. Returns post ID, title, status, and last modified date.', inputSchema: { type: 'object' as const, properties: { per_page: { type: 'number' as const, description: 'Number of posts to return (default: 10, max: 100)', default: 10, }, page: { type: 'number' as const, description: 'Page number for pagination (default: 1)', default: 1, }, status: { type: 'string' as const, description: 'Filter by status: publish, draft, private, or any', enum: ['publish', 'draft', 'private', 'any'], default: 'publish', }, search: { type: 'string' as const, description: 'Search term to filter posts by title or content', }, }, required: [], },