Skip to main content
Glama
study-flamingo

D&D MCP Server

add_item_to_character

Add items to a character's inventory in D&D campaigns by specifying character, item name, quantity, type, weight, and value for inventory management.

Instructions

Add an item to a character's inventory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
character_name_or_idYesName or ID of the character to receive the item.
item_nameYesItem name
descriptionNoItem description
quantityNoQuantity
item_typeNoItem typemisc
weightNoItem weight
valueNoItem value (e.g., '50 gp')

Implementation Reference

  • The main tool handler decorated with @mcp.tool. It retrieves the character by name or ID, creates a new Item with the provided parameters, appends it to the character's inventory list, and updates the storage to persist the change. Returns a confirmation message.
    @mcp.tool
    def add_item_to_character(
        character_name_or_id: Annotated[str, Field(description="Name or ID of the character to receive the item.")],
        item_name: Annotated[str, Field(description="Item name")],
        description: Annotated[str | None, Field(description="Item description")] = None,
        quantity: Annotated[int, Field(description="Quantity", ge=1)] = 1,
        item_type: Annotated[Literal["weapon", "armor", "consumable", "misc"], Field(description="Item type")] = "misc",
        weight: Annotated[float | None, Field(description="Item weight", ge=0)] = None,
        value: Annotated[str | None, Field(description="Item value (e.g., '50 gp')")] = None,
    ) -> str:
        """Add an item to a character's inventory."""
        character = storage.get_character(character_name_or_id)
        if not character:
            return f"❌ Character '{character_name_or_id}' not found!"
    
        item = Item(
            name=item_name,
            description=description,
            quantity=quantity,
            item_type=item_type,
            weight=weight,
            value=value
        )
    
        character.inventory.append(item)
        storage.update_character(str(character.id), inventory=character.inventory)
    
        return f"Added {item.quantity}x {item.name} to {character.name}'s inventory"
  • Input schema defined using Pydantic Annotated fields with descriptions, constraints (e.g., quantity >=1), and Literal types for item_type.
        character_name_or_id: Annotated[str, Field(description="Name or ID of the character to receive the item.")],
        item_name: Annotated[str, Field(description="Item name")],
        description: Annotated[str | None, Field(description="Item description")] = None,
        quantity: Annotated[int, Field(description="Quantity", ge=1)] = 1,
        item_type: Annotated[Literal["weapon", "armor", "consumable", "misc"], Field(description="Item type")] = "misc",
        weight: Annotated[float | None, Field(description="Item weight", ge=0)] = None,
        value: Annotated[str | None, Field(description="Item value (e.g., '50 gp')")] = None,
    ) -> str:
  • The @mcp.tool decorator registers the function as an MCP tool.
    @mcp.tool
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It states the action ('Add an item') but doesn't describe what happens on success/failure, whether duplicates are allowed, if inventory limits exist, or how the system handles the addition. For a mutation tool with zero annotation coverage, this leaves significant behavioral gaps unaddressed.

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 a single, clear sentence that states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every word earning its place. No structural issues or verbosity detract from its clarity.

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

Completeness2/5

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

Given this is a mutation tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after adding the item (e.g., returns success confirmation, updated character object, or nothing), doesn't mention error conditions, and provides minimal behavioral context. For a 7-parameter tool that modifies game state, more completeness is needed.

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?

Schema description coverage is 100%, so the schema already documents all 7 parameters thoroughly with descriptions, types, defaults, and constraints. The description adds no additional parameter information beyond what's in the schema. According to guidelines, when schema coverage is high (>80%), the baseline score is 3 even with no param info in the description.

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

Purpose4/5

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

The description clearly states the verb ('Add') and resource ('item to a character's inventory'), making the purpose immediately understandable. It distinguishes from siblings like 'update_character' or 'create_character' by focusing specifically on inventory management. However, it doesn't explicitly differentiate from potential inventory-related tools that might exist (though none are listed among siblings).

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., character must exist), whether it's for new items or existing ones, or how it relates to similar operations like 'update_character' which might also modify inventory. No explicit when/when-not statements or alternative tool references are included.

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/study-flamingo/gamemaster-mcp'

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