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
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Title of the page |
Implementation Reference
- index.ts:829-874 (handler)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 ) } ] }; }
- index.ts:569-582 (schema)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 ] }));
- index.ts:451-458 (helper)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" }); }