MinecraftWiki_getCategoriesForPage
Retrieve categories linked to a specific Minecraft Wiki page to organize and navigate content efficiently using the Minecraft Wiki MCP server.
Instructions
Get categories associated with a specific page.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Title of the Minecraft Wiki page |
Implementation Reference
- src/services/wiki.service.ts:166-194 (handler)Implements the core logic for retrieving categories associated with a specific Minecraft Wiki page using the MediaWiki API's query prop='categories'. Formats and returns the result as JSON.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)), }); }
- src/types/tools.ts:110-123 (schema)Defines the Tool schema including name, description, and inputSchema for the MinecraftWiki_getCategoriesForPage tool.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 in the MCP server's CallToolRequestHandler switch statement, validating arguments and calling the wikiService handler.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/types/guards.ts:65-72 (schema)Type guard function for validating the input arguments to the getCategoriesForPage tool.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" ); }