get-categories
Retrieve all categories from hafiz.blog (WordPress.com) to organize or filter content effectively using the Weather & WordPress MCP Server integration.
Instructions
Get all categories available on hafiz.blog (WordPress.com)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:215-242 (registration)Registration of the 'get-categories' MCP tool using server.tool(). Includes tool name, description, empty input schema ({}), and inline asynchronous handler function that fetches categories from the WordPress.com API for hafiz.blog, formats them, and returns as MCP text content.server.tool( "get-categories", "Get all categories available on hafiz.blog (WordPress.com)", {}, async () => { const categoriesUrl = `${WP_COM_API_BASE}/categories?per_page=50&_fields=id,name,slug`; const categories = await fetchJson<WPCategory[]>(categoriesUrl); if (!categories || categories.length === 0) { return { content: [{ type: "text", text: "No categories found" }], }; } const formattedCategories = categories.map((category) => `Category: ${category.name} (Slug: ${category.slug})` ); return { content: [ { type: "text", text: `Categories on hafiz.blog:\n\n${formattedCategories.join("\n")}`, }, ], }; } );
- src/index.ts:209-213 (schema)TypeScript interface defining the expected structure of WordPress category objects returned by the API, used for type safety in the fetchJson call within the get-categories handler.interface WPCategory { id: number; name: string; slug: string; }