Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

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

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