get_categories
Retrieve categories or pages from the Consumer Rights Wiki to explore topics like privacy violations, dark patterns, and deceptive pricing practices.
Instructions
Get all categories or pages in a specific category
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Category name (without Category: prefix). If empty, lists all categories. | |
| limit | No | Number of results to return (default: 20, max: 50) |
Implementation Reference
- src/index.ts:384-449 (handler)The handler function that executes the 'get_categories' tool. It handles two cases: listing pages in a specific category using 'categorymembers' or listing all categories using 'allcategories' via the wiki API.private async getCategories(args: any) { const { category, limit = 20 } = args; if (category) { // Get pages in a specific category const data = await this.makeApiRequest({ action: 'query', list: 'categorymembers', cmtitle: `Category:${category}`, cmlimit: Math.min(limit, 50).toString(), cmprop: 'ids|title|timestamp', }); if (data.error) { throw new McpError(ErrorCode.InternalError, data.error.info); } const members = data.query?.categorymembers || []; return { content: [ { type: 'text', text: JSON.stringify({ category: `Category:${category}`, members: members.map((member: any) => ({ title: member.title, pageid: member.pageid, timestamp: member.timestamp, url: `${WIKI_BASE_URL}/${member.title.replace(/ /g, '_')}`, })), }, null, 2), }, ], }; } else { // List all categories const data = await this.makeApiRequest({ action: 'query', list: 'allcategories', aclimit: Math.min(limit, 50).toString(), acprop: 'size', }); if (data.error) { throw new McpError(ErrorCode.InternalError, data.error.info); } const categories = data.query?.allcategories || []; return { content: [ { type: 'text', text: JSON.stringify({ categories: categories.map((cat: any) => ({ name: cat['*'], size: cat.size, url: `${WIKI_BASE_URL}/Category:${cat['*'].replace(/ /g, '_')}`, })), }, null, 2), }, ], }; } }
- src/index.ts:135-147 (schema)Input schema definition for the 'get_categories' tool, specifying parameters 'category' (optional string) and 'limit' (optional number).inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category name (without Category: prefix). If empty, lists all categories.', }, limit: { type: 'number', description: 'Number of results to return (default: 20, max: 50)', default: 20, }, },
- src/index.ts:132-149 (registration)Registration of the 'get_categories' tool in the ListTools response, including name, description, and input schema.{ name: 'get_categories', description: 'Get all categories or pages in a specific category', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category name (without Category: prefix). If empty, lists all categories.', }, limit: { type: 'number', description: 'Number of results to return (default: 20, max: 50)', default: 20, }, }, }, },
- src/index.ts:177-180 (registration)Dispatch case in the CallToolRequest handler that routes 'get_categories' calls to the getCategories method.case 'get_categories': return this.getCategories(request.params.arguments); case 'get_page_sections': return this.getPageSections(request.params.arguments);