Skip to main content
Glama

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
NameRequiredDescriptionDefault
participantsYesCombat participants with initiative order

Implementation Reference

  • 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'}"
  • Registers the start_combat function as an MCP tool using the FastMCP decorator.
    @mcp.tool
  • 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:

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