wpnav_list_comments
Retrieve and filter WordPress comments by status, post ID, or pagination to manage comment moderation and organization.
Instructions
List WordPress comments with optional filtering. Returns comment ID, author, content, and status.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number for pagination (default: 1) | |
| per_page | No | Number of comments to return (default: 10, max: 100) | |
| status | No | Filter by status: approve, hold, spam, trash, any | |
| post | No | Filter by post ID |
Implementation Reference
- src/tools/content/index.ts:885-896 (handler)The core handler function for the wpnav_list_comments tool. It validates pagination parameters, constructs a query string for filtering, fetches comments from the WordPress REST API (/wp/v2/comments), extracts a summary of relevant fields (id, author_name, content, status, post, date), and returns a formatted JSON response.handler: async (args, context) => { const { page, per_page } = validatePagination(args); const qs = buildQueryString({ page, per_page, status: args.status, post: args.post }); const comments = await context.wpRequest(`/wp/v2/comments?${qs}`); const summary = comments.map((c: any) => extractSummary(c, ['id', 'author_name', 'content.rendered', 'status', 'post', 'date'])); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(summary, null, 2)) }], }; },
- src/tools/content/index.ts:874-883 (schema)Input schema defining the parameters for the wpnav_list_comments tool: pagination (page, per_page), status filter, and post filter.inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (default: 1)' }, per_page: { type: 'number', description: 'Number of comments to return (default: 10, max: 100)' }, status: { type: 'string', enum: ['approve', 'hold', 'spam', 'trash', 'any'], description: 'Filter by status: approve, hold, spam, trash, any' }, post: { type: 'number', description: 'Filter by post ID' }, }, required: [], },
- src/tools/content/index.ts:870-898 (registration)Full tool registration block including name, description, input schema, handler function, and category for wpnav_list_comments.toolRegistry.register({ definition: { name: 'wpnav_list_comments', description: 'List WordPress comments with optional filtering. Returns comment ID, author, content, and status.', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number for pagination (default: 1)' }, per_page: { type: 'number', description: 'Number of comments to return (default: 10, max: 100)' }, status: { type: 'string', enum: ['approve', 'hold', 'spam', 'trash', 'any'], description: 'Filter by status: approve, hold, spam, trash, any' }, post: { type: 'number', description: 'Filter by post ID' }, }, required: [], }, }, handler: async (args, context) => { const { page, per_page } = validatePagination(args); const qs = buildQueryString({ page, per_page, status: args.status, post: args.post }); const comments = await context.wpRequest(`/wp/v2/comments?${qs}`); const summary = comments.map((c: any) => extractSummary(c, ['id', 'author_name', 'content.rendered', 'status', 'post', 'date'])); return { content: [{ type: 'text', text: context.clampText(JSON.stringify(summary, null, 2)) }], }; }, category: ToolCategory.CONTENT, });
- src/tools.ts:374-402 (schema)Static schema definition for wpnav_list_comments in the tools list, likely used for MCP protocol exposure or TypeScript types.{ name: 'wpnav_list_comments', description: 'List WordPress comments with optional filtering. Returns comment ID, author, content, and status.', inputSchema: { type: 'object' as const, properties: { per_page: { type: 'number' as const, description: 'Number of comments 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: approve, hold, spam, trash, any', enum: ['approve', 'hold', 'spam', 'trash', 'any'], }, post: { type: 'number' as const, description: 'Filter by post ID', }, }, required: [], },