update_game
Modify game details in your Lutris library by updating fields like name, platform, directory, or executable path to keep your gaming collection organized.
Instructions
Update fields on an existing game
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Game ID to update | |
| name | No | ||
| slug | No | ||
| runner | No | ||
| platform | No | ||
| directory | No | ||
| executable | No | ||
| year | No | ||
| service | No | ||
| service_id | No | ||
| installed | No | ||
| sortname | No | ||
| discord_id | No |
Implementation Reference
- src/tools/games.ts:154-202 (handler)The `update_game` tool registration and handler in `src/tools/games.ts`. It validates input using Zod and calls the database `updateGame` function.
server.tool( "update_game", "Update fields on an existing game", { id: z.coerce.number().describe("Game ID to update"), name: z.string().optional(), slug: z.string().optional(), runner: z.string().optional(), platform: z.string().optional(), directory: z.string().optional(), executable: z.string().optional(), year: z.coerce.number().optional(), service: z.string().optional(), service_id: z.string().optional(), installed: z.boolean().optional(), sortname: z.string().optional(), discord_id: z.string().optional(), }, async (params) => { try { const { id, installed, ...rest } = params; const existing = getGameById(id); if (!existing) { return { content: [{ type: "text", text: `Game with id ${id} not found.` }], isError: true, }; } const updates: Record<string, unknown> = {}; for (const [k, v] of Object.entries(rest)) { if (v !== undefined) updates[k] = v; } if (installed !== undefined) updates.installed = installed ? 1 : 0; const game = updateGame(id, updates); return { content: [ { type: "text", text: JSON.stringify({ message: "Game updated", game }, null, 2), }, ], }; } catch (error) { return handleError(error); } } ); - src/db/queries.ts:116-130 (handler)The actual database implementation of `updateGame` that performs the SQL update query.
export function updateGame( id: number, updates: Partial<Omit<Game, "id">> ): Game | undefined { const db = getDatabase(); const fields = Object.keys(updates); if (fields.length === 0) return getGameById(id); const sets = fields.map((f) => `${f} = :${f}`).join(", "); db.prepare(`UPDATE games SET ${sets} WHERE id = :id`).run({ ...updates, id, } as Record<string, unknown>); return getGameById(id); }