Skip to main content
Glama

wp_create_category

Create a new category in WordPress to organize content, specifying name and optional description for improved site structure.

Instructions

Creates a new category.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
nameYesThe name of the category.
descriptionNoThe description for the category.

Implementation Reference

  • The core handler function for the wp_create_category tool. It casts input parameters to CreateCategoryRequest type and delegates to the WordPressClient's createCategory method, returning a formatted success message or propagating errors.
    public async handleCreateCategory(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const createParams = params as unknown as CreateCategoryRequest;
      try {
        const category = await client.createCategory(createParams);
        return `✅ Category "${category.name}" created successfully with ID: ${category.id}.`;
      } catch (_error) {
        throw new Error(`Failed to create category: ${getErrorMessage(_error)}`);
      }
    }
  • Tool registration within TaxonomyTools.getTools() method, defining the tool's name, description, input parameters schema, and binding to the handler function.
    {
      name: "wp_create_category",
      description: "Creates a new category.",
      parameters: [
        {
          name: "name",
          type: "string",
          required: true,
          description: "The name of the category.",
        },
        {
          name: "description",
          type: "string",
          description: "The description for the category.",
        },
      ],
      handler: this.handleCreateCategory.bind(this),
    },
  • TypeScript interface defining the structure of CreateCategoryRequest used for type safety and validation in the category creation process.
    export interface CreateCategoryRequest {
      name: string;
      description?: string;
      slug?: string;
      parent?: number;
      meta?: WordPressMeta;
    }

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