get_categories
Retrieve all categories associated with a specific page title on Wizzypedia to streamline content organization and navigation.
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)MCP tool handler for 'get_categories': extracts title from arguments, calls wikiClient.getCategories, handles missing page, extracts category titles from API response, returns 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:451-458 (helper)MediaWikiClient helper method that performs the API query to retrieve categories for the given page title.async getCategories(title: string): Promise<any> { return this.makeApiCall({ action: "query", prop: "categories", titles: title, cllimit: "max" }); }
- index.ts:569-582 (schema)Tool definition including name, description, and input schema validating the required 'title' parameter.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)Registers the tool by including GET_CATEGORIES_TOOL in the list returned for ListToolsRequestSchema.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ SEARCH_PAGES_TOOL, READ_PAGE_TOOL, CREATE_PAGE_TOOL, UPDATE_PAGE_TOOL, GET_PAGE_HISTORY_TOOL, GET_CATEGORIES_TOOL ] }));