Skip to main content
Glama

update_character

Modify a Dungeons & Dragons character's properties including name, stats, background, hit points, and alignment using the character's name or ID on the D&D MCP Server.

Instructions

Update a character's properties.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
alignmentNoCharacter alignment
armor_classNoArmor class
backgroundNoCharacter background
bioNoThe character's backstory, personality, and motivations.
charismaNoCharisma score
constitutionNoConstitution score
descriptionNoA brief description of the character's appearance and demeanor.
dexterityNoDexterity score
hit_points_currentNoCurrent hit points
hit_points_maxNoMaximum hit points
inspirationNoInspiration status
intelligenceNoIntelligence score
nameNoNew character name. If you change this, you must use the character's ID to identify them.
name_or_idYesThe name or ID of the character to update.
notesNoAdditional notes about the character
player_nameNoThe name of the player in control of this character
strengthNoStrength score
temporary_hit_pointsNoTemporary hit points
wisdomNoWisdom score

Implementation Reference

  • MCP tool handler for 'update_character', decorated with @mcp.tool (registration), includes input schema via Annotated[Field] parameters. Calls storage layer to persist changes.
    @mcp.tool def update_character( name_or_id: Annotated[str, Field(description="The name or ID of the character to update.")], name: Annotated[str | None, Field(description="New character name. If you change this, you must use the character's ID to identify them.")] = None, 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, hit_points_current: Annotated[int | None, Field(description="Current hit points", ge=0)] = None, hit_points_max: Annotated[int | None, Field(description="Maximum hit points", ge=1)] = None, temporary_hit_points: Annotated[int | None, Field(description="Temporary hit points", ge=0)] = None, armor_class: Annotated[int | None, Field(description="Armor class")] = None, inspiration: Annotated[bool | None, Field(description="Inspiration status")] = None, notes: Annotated[str | None, Field(description="Additional notes about the character")] = None, strength: Annotated[int | None, Field(description="Strength score", ge=1, le=30)] = None, dexterity: Annotated[int | None, Field(description="Dexterity score", ge=1, le=30)] = None, constitution: Annotated[int | None, Field(description="Constitution score", ge=1, le=30)] = None, intelligence: Annotated[int | None, Field(description="Intelligence score", ge=1, le=30)] = None, wisdom: Annotated[int | None, Field(description="Wisdom score", ge=1, le=30)] = None, charisma: Annotated[int | None, Field(description="Charisma score", ge=1, le=30)] = None, ) -> str: """Update a character's properties.""" character = storage.get_character(name_or_id) if not character: return f"❌ Character '{name_or_id}' not found." updates = {k: v for k, v in locals().items() if v is not None and k not in ["name_or_id", "character"]} updated_fields = [f"{key.replace('_', ' ')}: {value}" for key, value in updates.items()] if not updates: return f"No updates provided for {character.name}." storage.update_character(str(character.id), **updates) return f"Updated {character.name}'s properties: {'; '.join(updated_fields)}."
  • Storage layer helper method that performs the actual update on the Character model, handles persistence by saving the campaign JSON.
    def update_character(self, name_or_id: str, **kwargs) -> None: """Update a character's data.""" if not self._current_campaign: raise ValueError("No current campaign") logger.info(f"📝 Attempting to update character '{name_or_id}' with data: {kwargs}") character = self._find_character(name_or_id) if not character: e = ValueError(f"❌ Character '{name_or_id}' not found!") logger.error(e) raise e original_name = character.name new_name = kwargs.get("name") for key, value in kwargs.items(): if hasattr(character, key): logger.debug(f"📝 Updating character '{original_name}': {key} -> {value}") setattr(character, key, value) character.updated_at = datetime.now() if new_name and new_name != original_name: # If name changed, update the dictionary key logger.debug(f"🏷️ Character name changed from '{original_name}' to '{new_name}'. Updating dictionary key.") self._current_campaign.characters[new_name] = self._current_campaign.characters.pop(original_name) self._current_campaign.updated_at = datetime.now() self._save_campaign() logger.info(f"✅ Character '{new_name or original_name}' updated successfully.")
  • Tool registration decorator @mcp.tool on the update_character handler.
    @mcp.tool
  • Input schema defined by Pydantic Annotated fields in the tool function signature.
    name_or_id: Annotated[str, Field(description="The name or ID of the character to update.")], name: Annotated[str | None, Field(description="New character name. If you change this, you must use the character's ID to identify them.")] = None, 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, hit_points_current: Annotated[int | None, Field(description="Current hit points", ge=0)] = None, hit_points_max: Annotated[int | None, Field(description="Maximum hit points", ge=1)] = None, temporary_hit_points: Annotated[int | None, Field(description="Temporary hit points", ge=0)] = None, armor_class: Annotated[int | None, Field(description="Armor class")] = None, inspiration: Annotated[bool | None, Field(description="Inspiration status")] = None, notes: Annotated[str | None, Field(description="Additional notes about the character")] = None, strength: Annotated[int | None, Field(description="Strength score", ge=1, le=30)] = None, dexterity: Annotated[int | None, Field(description="Dexterity score", ge=1, le=30)] = None, constitution: Annotated[int | None, Field(description="Constitution score", ge=1, le=30)] = None, intelligence: Annotated[int | None, Field(description="Intelligence score", ge=1, le=30)] = None, wisdom: Annotated[int | None, Field(description="Wisdom score", ge=1, le=30)] = None, charisma: Annotated[int | None, Field(description="Charisma score", ge=1, le=30)] = None, ) -> str:

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