get_character
Retrieve detailed Dungeons & Dragons character information by name or ID to support campaign management and gameplay.
Instructions
Get detailed character information.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name_or_id | Yes | Character name or ID |
Implementation Reference
- src/gamemaster_mcp/main.py:165-199 (handler)The @mcp.tool-decorated handler function that implements the 'get_character' tool logic. This is the primary entry point for the MCP tool, which fetches character data via storage and returns formatted information. The function signature defines the input schema via Annotated types.@mcp.tool def get_character( name_or_id: Annotated[str, Field(description="Character name or ID")] ) -> str: """Get detailed character information.""" character = storage.get_character(name_or_id) if not character: return f"❌ Character '{name_or_id}' not found." char_info = f"""**{character.name}** (`{character.id}`) Level {character.character_class.level} {character.race.name} {character.character_class.name} **Player:** {character.player_name or 'N/A'} **Background:** {character.background or 'N/A'} **Alignment:** {character.alignment or 'N/A'} **Description:** {character.description or 'No description provided.'} **Bio:** {character.bio or 'No bio provided.'} **Ability Scores:** • STR: {character.abilities['strength'].score} ({character.abilities['strength'].mod:+d}) • DEX: {character.abilities['dexterity'].score} ({character.abilities['dexterity'].mod:+d}) • CON: {character.abilities['constitution'].score} ({character.abilities['constitution'].mod:+d}) • INT: {character.abilities['intelligence'].score} ({character.abilities['intelligence'].mod:+d}) • WIS: {character.abilities['wisdom'].score} ({character.abilities['wisdom'].mod:+d}) • CHA: {character.abilities['charisma'].score} ({character.abilities['charisma'].mod:+d}) **Combat Stats:** • AC: {character.armor_class} • HP: {character.hit_points_current}/{character.hit_points_max} • Temp HP: {character.temporary_hit_points} **Inventory:** {len(character.inventory)} items """ return char_info
- Supporting method in the DnDStorage class that retrieves a Character object by name or ID, used by the main handler.def get_character(self, name_or_id: str) -> Character | None: """Get a character by name or ID.""" char = self._find_character(name_or_id) if not char: logger.error(f"❌ Character '{name_or_id}' not found!") return None logger.debug(f"✅ Found character '{char.name}'") return char
- src/gamemaster_mcp/main.py:165-165 (registration)The @mcp.tool decorator registers the get_character function as an MCP tool with the name 'get_character'.@mcp.tool