Skip to main content
Glama

MinecraftWiki_getCategoriesForPage

Retrieve categories for a specific Minecraft Wiki page to organize content and understand page context.

Instructions

Get categories associated with a specific page.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the Minecraft Wiki page

Implementation Reference

  • Implements the core logic for fetching categories associated with a Minecraft Wiki page using the MediaWiki API (prop=categories), handles errors, formats titles, and returns JSON response.
    async getCategoriesForPage(title: string): Promise<string> {
      const response = await apiService.get<WikiResponse, Record<string, unknown>>("", {
        action: "query",
        titles: title,
        prop: "categories",
      });
    
      const pages = response.query?.pages;
      if (!pages) {
        throw new Error(`Failed to get categories for "${title}"`);
      }
    
      const page = Object.values(pages)[0];
      if (page.missing) {
        throw new Error(`Page "${title}" not found`);
      }
    
      if (!page.categories?.length) {
        return JSON.stringify({
          title: formatMCPText(title),
          categories: [],
        });
      }
    
      return JSON.stringify({
        title: formatMCPText(title),
        categories: page.categories.map((cat) => formatMCPText(cat.title)),
      });
    }
  • Defines the MCP Tool schema including name, description, and input schema requiring a 'title' string parameter.
    export const GET_CATEGORIES_FOR_PAGE_MINECRAFTWIKI_TOOL: Tool = {
      name: "MinecraftWiki_getCategoriesForPage",
      description: "Get categories associated with a specific page.",
      inputSchema: {
        type: "object",
        properties: {
          title: {
            type: "string",
            description: "Title of the Minecraft Wiki page",
          },
        },
        required: ["title"],
      },
    };
  • src/server.ts:122-128 (registration)
    Registers the tool execution handler in the MCP server's CallToolRequestSchema, validates args with guard, and delegates to wikiService.getCategoriesForPage.
    case GET_CATEGORIES_FOR_PAGE_MINECRAFTWIKI_TOOL.name: {
      if (!isGetCategoriesForPageArgs(args)) {
        throw new Error("Invalid arguments for getCategoriesForPage");
      }
      const results = await wikiService.getCategoriesForPage(args.title);
      return { content: [{ type: "text", text: results }] };
    }
  • src/server.ts:48-60 (registration)
    Registers the tool in the ListToolsRequestSchema response, making it discoverable by MCP clients.
    // Register tool handlers
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        SEARCH_WIKI_MINECRAFTWIKI_TOOL,
        GET_PAGE_SUMMARY_MINECRAFTWIKI_TOOL,
        GET_SECTIONS_IN_PAGE_MINECRAFTWIKI_TOOL,
        GET_PAGE_SECTION_MINECRAFTWIKI_TOOL,
        GET_PAGE_CONTENT_MINECRAFTWIKI_TOOL,
        RESOLVE_REDIRECT_MINECRAFTWIKI_TOOL,
        LIST_CATEGORY_MEMBERS_MINECRAFTWIKI_TOOL,
        LIST_ALL_CATEGORIES_MINECRAFTWIKI_TOOL,
        GET_CATEGORIES_FOR_PAGE_MINECRAFTWIKI_TOOL,
      ],
  • Type guard function to validate input arguments conform to the tool's schema (requires 'title' string). Used in tool handler registration.
    export function isGetCategoriesForPageArgs(args: unknown): args is { title: string } {
      return (
        typeof args === "object" &&
        args !== null &&
        "title" in args &&
        typeof (args as { title: string }).title === "string"
      );
    }

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/L3-N0X/Minecraft-Wiki-MCP'

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