Skip to main content
Glama

wp_create_comment

Add a comment to a WordPress post by specifying the post ID, comment content, and optional author details to facilitate user engagement and feedback.

Instructions

Creates a new comment on a post.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
postYesThe ID of the post to comment on.
contentYesThe content of the comment.
author_nameNoThe name of the comment author.
author_emailNoThe email of the comment author.

Implementation Reference

  • MCP tool registration for 'wp_create_comment', including name, description, input schema (parameters), and handler reference.
    {
      name: "wp_create_comment",
      description: "Creates a new comment on a post.",
      parameters: [
        {
          name: "post",
          type: "number",
          required: true,
          description: "The ID of the post to comment on.",
        },
        {
          name: "content",
          type: "string",
          required: true,
          description: "The content of the comment.",
        },
        {
          name: "author_name",
          type: "string",
          description: "The name of the comment author.",
        },
        {
          name: "author_email",
          type: "string",
          description: "The email of the comment author.",
        },
      ],
      handler: this.handleCreateComment.bind(this),
    },
  • The core handler function for the 'wp_create_comment' tool. It casts input parameters to CreateCommentRequest, calls the WordPressClient's createComment method, and returns a success message with the new comment ID or throws a formatted error.
    public async handleCreateComment(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const createParams = params as unknown as CreateCommentRequest;
      try {
        const comment = await client.createComment(createParams);
        return `✅ Comment created successfully with ID: ${comment.id}`;
      } catch (_error) {
        throw new Error(`Failed to create comment: ${getErrorMessage(_error)}`);
      }
    }

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