start_combat
Initiate a combat encounter in Dungeons & Dragons campaigns by specifying participants and their initiative order using the D&D MCP Server tool.
Instructions
Start a combat encounter.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| participants | Yes | Combat participants with initiative order |
Implementation Reference
- src/gamemaster_mcp/main.py:615-634 (handler)The handler function for the 'start_combat' tool. It takes a list of participant dictionaries, sorts them by initiative, updates the game state to start combat, sets the initiative order and current turn, and returns a formatted message with the initiative order.@mcp.tool def start_combat( participants: Annotated[list[dict], Field(description="Combat participants with initiative order")] ) -> str: """Start a combat encounter.""" # Sort by initiative (highest first) initiative_order = sorted(participants, key=lambda x: x.get("initiative", 0), reverse=True) storage.update_game_state( in_combat=True, initiative_order=initiative_order, current_turn=initiative_order[0]["name"] if initiative_order else None ) order_text = "\n".join([ f"{i+1}. {p['name']} (Initiative: {p.get('initiative', 0)})" for i, p in enumerate(initiative_order) ]) return f"**Combat Started!**\n\n**Initiative Order:**\n{order_text}\n\n**Current Turn:** {initiative_order[0]['name'] if initiative_order else 'None'}"
- src/gamemaster_mcp/main.py:615-615 (registration)Registers the start_combat function as an MCP tool using the FastMCP decorator.@mcp.tool
- src/gamemaster_mcp/main.py:616-618 (schema)Input schema defined via Annotated[list[dict]] with Pydantic Field description for the participants parameter.def start_combat( participants: Annotated[list[dict], Field(description="Combat participants with initiative order")] ) -> str: