wp_update_category
Modify an existing WordPress category by updating its name or other properties using the category ID.
Instructions
Updates an existing category.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | The ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured. | |
| id | Yes | The ID of the category to update. | |
| name | No | The new name for the category. |
Implementation Reference
- src/tools/taxonomies.ts:82-98 (registration)Registration of the 'wp_update_category' tool within TaxonomyTools.getTools(), including name, description, input parameters schema, and handler binding.{ name: "wp_update_category", description: "Updates an existing category.", parameters: [ { name: "id", type: "number", required: true, description: "The ID of the category to update.", }, { name: "name", type: "string", description: "The new name for the category.", }, ], handler: this.handleUpdateCategory.bind(this),
- src/tools/taxonomies.ts:228-236 (handler)The core handler function for the 'wp_update_category' tool. Casts input parameters to UpdateCategoryRequest type and invokes the WordPressClient's updateCategory method, handling success and error responses.public async handleUpdateCategory(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const updateParams = params as unknown as UpdateCategoryRequest; try { const category = await client.updateCategory(updateParams); return `✅ Category ${category.id} updated successfully.`; } catch (_error) { throw new Error(`Failed to update category: ${getErrorMessage(_error)}`); } }
- src/types/wordpress.ts:474-484 (schema)TypeScript interface definitions for category requests. UpdateCategoryRequest (extends Partial<CreateCategoryRequest> with required id) provides input schema validation for the tool handler.export interface CreateCategoryRequest { name: string; description?: string; slug?: string; parent?: number; meta?: WordPressMeta; } export interface UpdateCategoryRequest extends Partial<CreateCategoryRequest> { id: number; }