Skip to main content
Glama
study-flamingo

D&D MCP Server

create_character

Generate a new Dungeons & Dragons player character by specifying name, class, level, race, ability scores, and background details for campaign integration.

Instructions

Create a new player character.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCharacter name
character_classYesCharacter class
class_levelYesClass level
raceYesCharacter race
player_nameNoThe name of the player in control of this character
descriptionNoA brief description of the character's appearance and demeanor.
bioNoThe character's backstory, personality, and motivations.
backgroundNoCharacter background
alignmentNoCharacter alignment
strengthNoStrength score
dexterityNoDexterity score
constitutionNoConstitution score
intelligenceNoIntelligence score
wisdomNoWisdom score
charismaNoCharisma score

Implementation Reference

  • The core handler function for the 'create_character' tool. It is registered via the @mcp.tool decorator. The function parameters with Annotated[Field] define the input schema. The logic constructs a Character model instance using provided parameters and persists it via storage.add_character.
    @mcp.tool
    def create_character(
        name: Annotated[str, Field(description="Character name")],
        character_class: Annotated[str, Field(description="Character class")],
        class_level: Annotated[int, Field(description="Class level", ge=1, le=20)],
        race: Annotated[str, Field(description="Character race")],
        player_name: Annotated[str | None, Field(description="The name of the player in control of this character")] = None,
        description: Annotated[str | None, Field(description="A brief description of the character's appearance and demeanor.")] = None,
        bio: Annotated[str | None, Field(description="The character's backstory, personality, and motivations.")] = None,
        background: Annotated[str | None, Field(description="Character background")] = None,
        alignment: Annotated[str | None, Field(description="Character alignment")] = None,
        strength: Annotated[int, Field(description="Strength score", ge=1, le=30)] = 10,
        dexterity: Annotated[int, Field(description="Dexterity score", ge=1, le=30)] = 10,
        constitution: Annotated[int, Field(description="Constitution score", ge=1, le=30)] = 10,
        intelligence: Annotated[int, Field(description="Intelligence score", ge=1, le=30)] = 10,
        wisdom: Annotated[int, Field(description="Wisdom score", ge=1, le=30)] = 10,
        charisma: Annotated[int, Field(description="Charisma score", ge=1, le=30)] = 10,
    ) -> str:
        """Create a new player character."""
        # Build ability scores
        abilities = {
            "strength": AbilityScore(score=strength),
            "dexterity": AbilityScore(score=dexterity),
            "constitution": AbilityScore(score=constitution),
            "intelligence": AbilityScore(score=intelligence),
            "wisdom": AbilityScore(score=wisdom),
            "charisma": AbilityScore(score=charisma),
        }
    
        character = Character(
            name=name,
            player_name=player_name,
            character_class=CharacterClass(name=character_class, level=class_level),
            race=Race(name=race),
            background=background,
            alignment=alignment,
            abilities=abilities,
            description=description,
            bio=bio,
        )
    
        storage.add_character(character)
        return f"Created character '{character.name}' (Level {character.character_class.level} {character.race.name} {character.character_class.name})"
  • Pydantic model for Character used internally by the create_character handler to structure the created character data.
    class CharacterClass(BaseModel):
        """Character class information."""
        name: str
        level: int = Field(ge=1, le=20)
        hit_dice: Annotated[str, "The type of hit dice for this character. E.g.. '1d8'"] = "1d4" # e.g., "1d8"
        subclass: Annotated[str | None, "The character's subclass."] = None
    
    
    class Race(BaseModel):
        """Character race information."""
        name: str
        subrace: str | None = None
        traits: list[str] = Field(default_factory=list)
    
    
    class Item(BaseModel):
        """Generic item model."""
        id: str = Field(default_factory=lambda: random(length=8))
        name: str
        description: str | None = None
        quantity: int = 1
        weight: float | None = None
        value: str | None = None  # e.g., "50 gp"
        item_type: str = "misc"  # weapon, armor, consumable, misc, etc.
        properties: dict[str, Any] = Field(default_factory=dict)
    
    
    class Spell(BaseModel):
        """Spell information."""
        id: str = Field(default_factory=lambda: random(length=8))
        name: str
        level: int = Field(ge=0, le=9)
        school: str
        casting_time: str
        range: int = Field(default=5, description="The range of the spell, in feet")
        duration: str
        components: list[str]  # V, S, M
        description: str
        material_components: str | None = None
        prepared: bool = False
    
    
    class Character(BaseModel):
  • Supporting Pydantic models (AbilityScore, CharacterClass, Race) used to construct the Character object in the handler.
    class AbilityScore(BaseModel):
        """D&D ability score with modifiers."""
        score: int = Field(ge=1, le=30, description="Raw ability score")
    
        @property
        def mod(self) -> int:
            """Calculate ability modifier."""
            return (self.score - 10) // 2
    
    
    class CharacterClass(BaseModel):
        """Character class information."""
        name: str
        level: int = Field(ge=1, le=20)
        hit_dice: Annotated[str, "The type of hit dice for this character. E.g.. '1d8'"] = "1d4" # e.g., "1d8"
        subclass: Annotated[str | None, "The character's subclass."] = None
    
    
    class Race(BaseModel):
        """Character race information."""
        name: str
        subrace: str | None = None
        traits: list[str] = Field(default_factory=list)
    
    
    class Item(BaseModel):
        """Generic item model."""
        id: str = Field(default_factory=lambda: random(length=8))
        name: str
        description: str | None = None
        quantity: int = 1
        weight: float | None = None
        value: str | None = None  # e.g., "50 gp"
        item_type: str = "misc"  # weapon, armor, consumable, misc, etc.
        properties: dict[str, Any] = Field(default_factory=dict)
    
    
    class Spell(BaseModel):
        """Spell information."""
        id: str = Field(default_factory=lambda: random(length=8))
        name: str
        level: int = Field(ge=0, le=9)
        school: str
        casting_time: str
        range: int = Field(default=5, description="The range of the spell, in feet")
        duration: str
        components: list[str]  # V, S, M
        description: str
        material_components: str | None = None
        prepared: bool = False
    
    
    class Character(BaseModel):
        """Complete character sheet."""
        # Basic Info
        id: str = Field(default_factory=lambda: random(length=8))
        name: str
        player_name: str | None = None
        character_class: CharacterClass
        race: Race
        background: str | None = None
        alignment: str | None = None
        description: str | None = None  # A brief description of the character's appearance and demeanor.
        bio: str | None = None  # The character's backstory, personality, and motivations.
    
        # Core Stats
        abilities: dict[str, AbilityScore] = Field(
            default_factory=lambda: {
                "strength": AbilityScore(score=10),
                "dexterity": AbilityScore(score=10),
                "constitution": AbilityScore(score=10),
                "intelligence": AbilityScore(score=10),
                "wisdom": AbilityScore(score=10),
                "charisma": AbilityScore(score=10),
            }
        )
    
        # Combat Stats
        armor_class: int = 10
        hit_points_max: int = 1
        hit_points_current: int = 1
        temporary_hit_points: int = 0
        hit_dice_remaining: str = "1d8"
        death_saves_success: int = Field(ge=0, le=3, default=0)
        death_saves_failure: int = Field(ge=0, le=3, default=0)
    
        # Skills & Proficiencies
        proficiency_bonus: int = 2
        skill_proficiencies: list[str] = Field(default_factory=list)
        saving_throw_proficiencies: list[str] = Field(default_factory=list)
    
        # Equipment
        inventory: list[Item] = Field(default_factory=list)
        equipment: dict[str, Item | None] = Field(
            default_factory=lambda: {
                "weapon_main": None,
                "weapon_off": None,
                "armor": None,
                "shield": None,
            }
        )
    
        # Spellcasting
        spellcasting_ability: str | None = None
        spell_slots: dict[int, int] = Field(default_factory=dict)  # level: max_slots
        spell_slots_used: dict[int, int] = Field(default_factory=dict)  # level: used_slots
        spells_known: list[Spell] = Field(default_factory=list)
    
        # Character Features
        features_and_traits: list[str] = Field(default_factory=list)
        languages: list[str] = Field(default_factory=list)
    
        # Misc
        inspiration: bool = False
        notes: str = ""
        created_at: datetime = Field(default_factory=datetime.now)
        updated_at: datetime = Field(default_factory=datetime.now)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Create' implies a write/mutation operation, the description doesn't address important behavioral aspects: whether this requires specific permissions, what happens on success/failure, whether character names must be unique, if there are validation rules beyond schema constraints, or what the response contains. For a mutation tool with 15 parameters and no annotation coverage, this is a significant gap.

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 maximally concise - a single clear sentence with zero wasted words. It's appropriately sized for a tool with a straightforward purpose, though this conciseness comes at the cost of completeness. Every word earns its place by communicating the core function.

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 the complexity (15 parameters, mutation operation) and lack of both annotations and output schema, the description is insufficiently complete. It doesn't explain what happens after creation, what validation occurs, whether there are side effects, or how this tool relates to the broader RPG system context. The agent would need to guess about important operational aspects despite the comprehensive parameter schema.

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%, with each parameter well-documented in the schema itself (e.g., 'Character name', 'Character class', 'Strength score'). The description adds no parameter information beyond what's already in the schema. According to the scoring rules, when schema_description_coverage is high (>80%), the baseline 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.

Purpose3/5

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

The description 'Create a new player character' clearly states the verb ('Create') and resource ('player character'), but it's quite basic and doesn't differentiate this tool from sibling tools like 'create_campaign', 'create_npc', or 'create_quest' beyond the obvious resource difference. It lacks specificity about what distinguishes character creation from other creation operations in this RPG system.

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. There's no mention of prerequisites (like needing an existing campaign), no indication of when to use this versus 'update_character' or 'bulk_update_characters', and no reference to related tools like 'get_character' or 'list_characters' for retrieval operations. The agent must infer usage from the tool name alone.

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