Skip to main content
Glama

add_component_to_game

Add printable components like card decks, boards, or boxes to a game project using catalog identifiers or stock part UUIDs. Specify quantity and optional display name to build your tabletop game.

Instructions

Add a printable component (card deck, board, box, etc.) or stock part to a game. Use a catalog identity (e.g., 'BridgeDeck') for printable components, or a stock part UUID. Requires authentication.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
game_idYesThe game ID to add the component to.
part_idYesThe component identity from the catalog (e.g., 'BridgeDeck', 'SmallTuckBox') or a stock part UUID.
quantityYesNumber of this component to include (e.g., 52 for a deck of cards).
nameNoOptional display name for this component within the game (max 255 chars).

Implementation Reference

  • The handler function `handleAddComponentToGame` manages the addition of components to a game, supporting both printable catalog products (via API path) and generic stock parts.
    export function handleAddComponentToGame(client: TgcClient) {
      return async (args: {
        game_id: string;
        part_id: string;
        quantity: number;
        name?: string;
      }): Promise<CallToolResult> => {
        // Check if part_id is a catalog product identity (printable component)
        const products = await client.getProducts();
        const catalogProduct = products.find((p) => p.identity === args.part_id);
    
        if (catalogProduct && catalogProduct.create_api) {
          // Strip leading /api prefix — the client's base URL already includes it
          const apiPath = catalogProduct.create_api.replace(/^\/api/, "");
          if (apiPath.includes("..") || apiPath.includes("//")) {
            throw new TgcError(
              `Invalid create_api path from catalog: "${catalogProduct.create_api}"`,
              "validation",
            );
          }
          const component = await client.createPrintableComponent(
            apiPath,
            catalogProduct.identity,
            args.game_id,
            args.name,
            args.quantity,
          );
          return {
            content: [
              {
                type: "text",
                text: `Printable component "${catalogProduct.name}" added to game successfully.\n\n${JSON.stringify(component, null, 2)}`,
              },
            ],
          };
        }
    
        // Fall back to stock part via /gamepart
        const part = await client.addGamePart(
          args.game_id,
          args.part_id,
          args.quantity,
          args.name,
        );
        return {
          content: [
            {
              type: "text",
              text: `Component added to game successfully.\n\n${JSON.stringify(part, null, 2)}`,
            },
          ],
        };
      };
    }
  • Input schema definition for `add_component_to_game`, including validation for game ID, part ID, quantity, and name.
    export const addComponentToGameInput = {
      game_id: safeId.describe("The game ID to add the component to."),
      part_id: safeId.describe(
        "The component identity from the catalog (e.g., 'BridgeDeck', 'SmallTuckBox') or a stock part UUID.",
      ),
      quantity: z
        .number()
        .int()
        .positive()
        .describe(
          "Number of this component to include (e.g., 52 for a deck of cards).",
        ),
      name: z
        .string()
        .trim()
        .max(255)
        .optional()
        .describe("Optional display name for this component within the game (max 255 chars)."),
    };
  • src/index.ts:113-119 (registration)
    Tool registration for `add_component_to_game` in the main server entry point, binding the schema and the handler.
    server.registerTool("add_component_to_game", {
      description:
        "Add a printable component (card deck, board, box, etc.) or stock part to a game. Use a catalog identity (e.g., 'BridgeDeck') for printable components, or a stock part UUID. Requires authentication.",
      inputSchema: schemas.addComponentToGameInput,
      annotations: { readOnlyHint: false },
    }, withErrorHandling(handleAddComponentToGame(client)));
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds value beyond the readOnlyHint annotation (which only indicates it's not read-only) by specifying authentication requirements, which is useful context. However, it lacks details on behavioral traits like whether the operation is idempotent, potential side effects, error conditions, or rate limits, leaving gaps in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by usage details and authentication requirement. Every sentence adds value without redundancy, making it efficient and well-structured for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation with authentication) and lack of output schema, the description is moderately complete. It covers the purpose, usage, and auth needs, but omits details on return values, error handling, or interactions with other tools like get_component_details, which could aid the agent in proper invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the schema already documents all parameters well. The description adds minimal semantics by mentioning catalog identities and stock part UUIDs for part_id, but does not provide additional meaning beyond what the schema offers, such as examples for game_id or name usage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add'), the resource ('a printable component or stock part'), and the target ('to a game'). It distinguishes from siblings by specifying component types (cards, boards, boxes) and using catalog identities or UUIDs, unlike generic tools like update_game or get_game_details.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: for adding components to games, with examples of component types and identifiers. It mentions authentication as a prerequisite. However, it does not explicitly state when not to use it or name alternatives among siblings, such as using update_game for other modifications.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/alex-gon/thegamecrafter-mcp-server'

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