Skip to main content
Glama
study-flamingo

D&D MCP Server

get_game_state

Retrieve the current state of your Dungeons & Dragons campaign, including characters, NPCs, locations, quests, and combat encounters for session tracking.

Instructions

Get the current game state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'get_game_state'. Fetches the game state from storage and returns a formatted string summary.
    @mcp.tool
    def get_game_state() -> str:
        """Get the current game state."""
        game_state = storage.get_game_state()
        if not game_state:
            return "No game state available."
    
        state_info = f"""**Game State**
    **Campaign:** {game_state.campaign_name}
    **Session:** {game_state.current_session}
    **Location:** {game_state.current_location or 'Unknown'}
    **Date (In-Game):** {game_state.current_date_in_game or 'Unknown'}
    **Party Level:** {game_state.party_level}
    **Party Funds:** {game_state.party_funds}
    **In Combat:** {'Yes' if game_state.in_combat else 'No'}
    
    **Active Quests:** {len(game_state.active_quests)}
    
    **Notes:** {game_state.notes or 'No current notes.'}
    """
    
        return state_info
  • Helper method in Storage class that retrieves the current GameState object from the active campaign.
    def get_game_state(self) -> GameState | None:
        """Get the current game state."""
        if not self._current_campaign:
            return None
        return self._current_campaign.game_state
  • Pydantic BaseModel defining the GameState data structure used by the tool.
    class GameState(BaseModel):
        """Current state of the game."""
        campaign_name: str
        current_session: int = 1
        current_date_in_game: str | None = None
        current_location: str | None = None
        active_quests: list[str] = Field(default_factory=list)
        party_level: int = 1
        party_funds: str = "0 gp"
        initiative_order: list[dict[str, Any]] = Field(default_factory=list)
        in_combat: bool = False
        current_turn: str | None = None
        notes: str = ""
        updated_at: datetime = Field(default_factory=datetime.now)

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