Skip to main content
Glama

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
NameRequiredDescriptionDefault
idYesGame ID to update
nameNo
slugNo
runnerNo
platformNo
directoryNo
executableNo
yearNo
serviceNo
service_idNo
installedNo
sortnameNo
discord_idNo

Implementation Reference

  • 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);
        }
      }
    );
  • 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);
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Praeses0/lutris-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server