list_categories
Retrieve all game categories with their associated game counts from the Lutris Linux gaming library database to organize and analyze your collection.
Instructions
List all categories with game counts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/categories.ts:29-38 (handler)The handler function for the list_categories tool.
async () => { try { const categories = listCategories(); return { content: [{ type: "text", text: JSON.stringify(categories, null, 2) }], }; } catch (error) { return handleError(error); } } - src/tools/categories.ts:25-39 (registration)Registration of the list_categories tool using the server.tool method.
server.tool( "list_categories", "List all categories with game counts", {}, async () => { try { const categories = listCategories(); return { content: [{ type: "text", text: JSON.stringify(categories, null, 2) }], }; } catch (error) { return handleError(error); } } ); - src/db/queries.ts:141-152 (helper)The database query function that performs the actual logic for listing categories.
export function listCategories(): CategoryWithCount[] { const db = getDatabase(); return db .prepare( `SELECT c.id, c.name, COUNT(gc.game_id) as game_count FROM categories c LEFT JOIN games_categories gc ON gc.category_id = c.id GROUP BY c.id, c.name ORDER BY c.name` ) .all() as CategoryWithCount[]; }