Skip to main content
Glama
cryppadotta
by cryppadotta

get_categories

Retrieve the categories associated with a specific Wizzypedia page by providing its title. This tool helps organize and classify wiki content for better navigation and content management.

Instructions

Get categories a page belongs to

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the page

Implementation Reference

  • Main handler for the 'get_categories' tool call within the MCP server's CallToolRequestSchema handler. Extracts the title argument, calls wikiClient.getCategories(title), processes the MediaWiki API response to handle missing pages and extract category titles, then returns a formatted JSON response.
    case "get_categories": {
      const { title } = request.params.arguments as { title: string };
      const result = await wikiClient.getCategories(title);
    
      const pages = result.query.pages;
      const page = pages[0];
    
      if (page.missing) {
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                {
                  title: page.title,
                  exists: false,
                  message: "Page does not exist"
                },
                null,
                2
              )
            }
          ]
        };
      }
    
      const categories = page.categories
        ? page.categories.map((cat: any) => cat.title)
        : [];
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              {
                title: page.title,
                categories
              },
              null,
              2
            )
          }
        ]
      };
    }
  • Tool schema definition for 'get_categories', including name, description, and input schema requiring a 'title' string.
    const GET_CATEGORIES_TOOL: Tool = {
      name: "get_categories",
      description: "Get categories a page belongs to",
      inputSchema: {
        type: "object",
        properties: {
          title: {
            type: "string",
            description: "Title of the page"
          }
        },
        required: ["title"]
      }
    };
  • index.ts:598-607 (registration)
    Registration of the 'get_categories' tool (via GET_CATEGORIES_TOOL) in the list tools request handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        SEARCH_PAGES_TOOL,
        READ_PAGE_TOOL,
        CREATE_PAGE_TOOL,
        UPDATE_PAGE_TOOL,
        GET_PAGE_HISTORY_TOOL,
        GET_CATEGORIES_TOOL
      ]
    }));
  • Helper method in MediaWikiClient class that performs the actual API call to retrieve categories for a given page title.
    async getCategories(title: string): Promise<any> {
      return this.makeApiCall({
        action: "query",
        prop: "categories",
        titles: title,
        cllimit: "max"
      });
    }

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/cryppadotta/mcp-wizzypedia'

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