Skip to main content
Glama

wp_list_comments

Retrieve and filter comments from a WordPress site, including options to limit results by post ID or comment status.

Instructions

Lists comments 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.
postNoLimit results to comments assigned to a specific post ID.
statusNoFilter by comment status.

Implementation Reference

  • Tool registration including name, description, input schema (parameters), and handler binding.
    { name: "wp_list_comments", description: "Lists comments from a WordPress site, with filters.", parameters: [ { name: "post", type: "number", description: "Limit results to comments assigned to a specific post ID.", }, { name: "status", type: "string", description: "Filter by comment status.", enum: ["hold", "approve", "spam", "trash"], }, ], handler: this.handleListComments.bind(this), },
  • Executes the tool logic: fetches comments via WordPressClient.getComments, formats a markdown list if found, or empty message; throws formatted error.
    public async handleListComments(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const queryParams = params as CommentQueryParams; try { const comments = await client.getComments(queryParams); if (comments.length === 0) { return "No comments found matching the criteria."; } const content = `Found ${comments.length} comments:\n\n` + comments .map( (c) => `- ID ${c.id}: By **${c.author_name}** on Post ${c.post} (${ c.status })\n > ${c.content.rendered.substring(0, 100)}...`, ) .join("\n"); return content; } catch (_error) { throw new Error(`Failed to list comments: ${getErrorMessage(_error)}`); } }
  • Input parameter schema definition for post ID filter (optional number) and status filter (optional enum).
    parameters: [ { name: "post", type: "number", description: "Limit results to comments assigned to a specific post ID.", }, { name: "status", type: "string", description: "Filter by comment status.", enum: ["hold", "approve", "spam", "trash"], }, ],

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