wp_get_category
Retrieve a specific WordPress category by its unique ID to access category details and structure for site management and content organization.
Instructions
Retrieves a single category by its ID.
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 unique identifier for the category. |
Implementation Reference
- src/tools/taxonomies.ts:202-216 (handler)The handler function that executes the wp_get_category tool. It fetches the category by ID from the WordPress client and returns a formatted details string.public async handleGetCategory(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { const { id } = params as { id: number }; try { const category = await client.getCategory(id); const content = `**Category Details (ID: ${category.id})**\n\n` + `- **Name:** ${category.name}\n` + `- **Slug:** ${category.slug}\n` + `- **Description:** ${category.description || "None"}\n` + `- **Post Count:** ${category.count}`; return content; } catch (_error) { throw new Error(`Failed to get category: ${getErrorMessage(_error)}`); } }
- src/tools/taxonomies.ts:51-63 (registration)Registers the wp_get_category tool in TaxonomyTools.getTools(), including schema (parameters), description, and handler binding.{ name: "wp_get_category", description: "Retrieves a single category by its ID.", parameters: [ { name: "id", type: "number", required: true, description: "The unique identifier for the category.", }, ], handler: this.handleGetCategory.bind(this), },