Skip to main content
Glama
hafizrahman

Weather & WordPress MCP Server

by hafizrahman

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
NameRequiredDescriptionDefault

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")}`, }, ], }; } );
  • 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; }

Other Tools

Related Tools

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/hafizrahman/wp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server