Skip to main content
Glama
study-flamingo

D&D MCP Server

next_turn

Advance combat to the next turn in Dungeons & Dragons campaigns to manage encounter flow and track initiative order.

Instructions

Advance to the next turn in combat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'next_turn' tool. It advances the current turn in an ongoing combat by finding the next participant in the initiative order and updating the game state. The @mcp.tool decorator also handles registration.
    @mcp.tool
    def next_turn() -> str:
        """Advance to the next turn in combat."""
        game_state = storage.get_game_state()
        if not game_state or not game_state.in_combat:
            return "Not currently in combat."
    
        if not game_state.initiative_order:
            return "No initiative order set."
    
        # Find current turn index and advance
        current_index = 0
        if game_state.current_turn:
            for i, participant in enumerate(game_state.initiative_order):
                if participant["name"] == game_state.current_turn:
                    current_index = i
                    break
    
        next_index = (current_index + 1) % len(game_state.initiative_order)
        next_participant = game_state.initiative_order[next_index]
    
        storage.update_game_state(current_turn=next_participant["name"])
    
        return f"**Next Turn:** {next_participant['name']}"

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