get_game_state
Retrieve the current game state on the D&D MCP Server to track campaign progress, manage encounters, and monitor session details for Dungeons & Dragons campaigns.
Instructions
Get the current game state.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gamemaster_mcp/main.py:591-612 (handler)The MCP tool handler for 'get_game_state'. Decorated with @mcp.tool for registration, retrieves GameState from storage and formats a markdown summary string.@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
- src/gamemaster_mcp/models.py:344-357 (schema)Pydantic BaseModel defining the GameState data structure used by the get_game_state 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)
- Storage class method that retrieves and returns the current GameState 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
- src/gamemaster_mcp/main.py:591-591 (registration)The @mcp.tool decorator registers the get_game_state function as an MCP tool.@mcp.tool