assign_category
Add a game to a category in your Lutris Linux gaming library to organize your collection.
Instructions
Add a game to a category
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| game_id | Yes | Game ID | |
| category_name | Yes | Category name |
Implementation Reference
- src/tools/categories.ts:64-103 (handler)Tool handler for "assign_category". Validates existence of the game, gets/creates the category, and calls the database function.
server.tool( "assign_category", "Add a game to a category", { game_id: z.coerce.number().describe("Game ID"), category_name: z.string().describe("Category name"), }, async (params) => { try { const game = getGameById(params.game_id); if (!game) { return { content: [{ type: "text", text: `Game with id ${params.game_id} not found.` }], isError: true, }; } let category = getCategoryByName(params.category_name); if (!category) { category = createCategory(params.category_name); } assignCategory(params.game_id, category.id); return { content: [ { type: "text", text: JSON.stringify( { message: `"${game.name}" assigned to "${category.name}".` }, null, 2 ), }, ], }; } catch (error) { return handleError(error); } } ); - src/db/queries.ts:169-174 (handler)Database implementation of the assign_category logic.
export function assignCategory(gameId: number, categoryId: number): void { const db = getDatabase(); db.prepare( "INSERT OR IGNORE INTO games_categories (game_id, category_id) VALUES (?, ?)" ).run(gameId, categoryId); }