Skip to main content
Glama
hafizrahman

Weather & WordPress MCP Server

by hafizrahman

get-categories

Retrieve all post categories from the hafiz.blog WordPress site to organize content and improve navigation.

Instructions

Get all categories available on hafiz.blog (WordPress.com)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'get-categories' tool. It fetches categories from the WordPress.com API endpoint, handles empty results, formats the category list with name and slug, and returns formatted text content.
    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 WordPress category structure used for typing the API response in the get-categories handler.
    interface WPCategory {
        id: number;
        name: string;
        slug: string;
    }
  • src/index.ts:215-242 (registration)
    Registration of the 'get-categories' tool using McpServer.tool method, with tool name, description, empty input schema (no parameters), and inline handler function.
    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")}`,
                    },
                ],
            };
        }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool retrieves categories but doesn't disclose behavioral traits like whether it's a read-only operation, what format the categories are returned in, if there are rate limits, authentication requirements, or potential side effects. The description is minimal and lacks essential operational context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose with zero wasted words. It's appropriately sized for a simple retrieval tool and front-loads the essential information without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. For a retrieval tool, it should ideally mention what the return format looks like (e.g., list of category objects with IDs and names) or any limitations. The current description provides only basic purpose without operational details needed for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, focusing instead on the tool's purpose. This meets the baseline expectation for tools without parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('all categories available on hafiz.blog'), providing specific scope and platform context. It distinguishes from siblings by focusing on categories rather than alerts, forecasts, or posts. However, it doesn't explicitly differentiate from hypothetical category-related siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention when this tool is appropriate compared to sibling tools like 'get-posts-by-category' or indicate any prerequisites or constraints for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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