update_game_state
Update Dungeons & Dragons campaign progress by modifying game state details like location, session number, in-game date, party level, funds, combat status, and notes using the D&D MCP Server.
Instructions
Update the current game state.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| current_date_in_game | No | Current in-game date | |
| current_location | No | Current party location | |
| current_session | No | Current session number | |
| in_combat | No | Whether party is in combat | |
| notes | No | Current situation notes | |
| party_funds | No | Party treasure/funds | |
| party_level | No | Average party level |
Implementation Reference
- src/gamemaster_mcp/main.py:561-589 (handler)MCP tool handler for 'update_game_state'. Defines input schema with optional parameters for game state fields. Collects provided kwargs and delegates to storage.update_game_state. Returns confirmation message. The @mcp.tool decorator handles registration.@mcp.tool def update_game_state( current_location: Annotated[str | None, Field(description="Current party location")] = None, current_session: Annotated[int | None, Field(description="Current session number", ge=1)] = None, current_date_in_game: Annotated[str | None, Field(description="Current in-game date")] = None, party_level: Annotated[int | None, Field(description="Average party level", ge=1, le=20)] = None, party_funds: Annotated[str | None, Field(description="Party treasure/funds")] = None, in_combat: Annotated[bool | None, Field(description="Whether party is in combat")] = None, notes: Annotated[str | None, Field(description="Current situation notes")] = None, ) -> str: """Update the current game state.""" kwargs = {} if current_location is not None: kwargs["current_location"] = current_location if current_session is not None: kwargs["current_session"] = current_session if current_date_in_game is not None: kwargs["current_date_in_game"] = current_date_in_game if party_level is not None: kwargs["party_level"] = party_level if party_funds is not None: kwargs["party_funds"] = party_funds if in_combat is not None: kwargs["in_combat"] = in_combat if notes is not None: kwargs["notes"] = notes storage.update_game_state(**kwargs) return "Updated game state"
- Helper method in Storage class that updates specified fields in the current campaign's game_state object using dynamic setattr, updates timestamps, and saves the campaign to persistence.def update_game_state(self, **kwargs) -> None: """Update the game state.""" if not self._current_campaign: raise ValueError("No current campaign") game_state = self._current_campaign.game_state for key, value in kwargs.items(): if hasattr(game_state, key): setattr(game_state, key, value) game_state.updated_at = datetime.now() self._current_campaign.updated_at = datetime.now() self._save_campaign()
- src/gamemaster_mcp/main.py:563-589 (schema)Input schema defined via Pydantic Annotated types in the tool handler function parameters, specifying optional fields for game state updates with descriptions and constraints.current_location: Annotated[str | None, Field(description="Current party location")] = None, current_session: Annotated[int | None, Field(description="Current session number", ge=1)] = None, current_date_in_game: Annotated[str | None, Field(description="Current in-game date")] = None, party_level: Annotated[int | None, Field(description="Average party level", ge=1, le=20)] = None, party_funds: Annotated[str | None, Field(description="Party treasure/funds")] = None, in_combat: Annotated[bool | None, Field(description="Whether party is in combat")] = None, notes: Annotated[str | None, Field(description="Current situation notes")] = None, ) -> str: """Update the current game state.""" kwargs = {} if current_location is not None: kwargs["current_location"] = current_location if current_session is not None: kwargs["current_session"] = current_session if current_date_in_game is not None: kwargs["current_date_in_game"] = current_date_in_game if party_level is not None: kwargs["party_level"] = party_level if party_funds is not None: kwargs["party_funds"] = party_funds if in_combat is not None: kwargs["in_combat"] = in_combat if notes is not None: kwargs["notes"] = notes storage.update_game_state(**kwargs) return "Updated game state"