Skip to main content
Glama

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
NameRequiredDescriptionDefault
game_idYesGame ID
category_nameYesCategory name

Implementation Reference

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

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