update_game_state
Modify Dungeons & Dragons campaign progress by updating location, session number, party level, combat status, and other game state details.
Instructions
Update the current game state.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "update_game_state"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| current_location | No | Current party location | |
| current_session | No | Current session number | |
| current_date_in_game | No | Current in-game date | |
| party_level | No | Average party level | |
| party_funds | No | Party treasure/funds | |
| in_combat | No | Whether party is in combat | |
| notes | No | Current situation notes |
Implementation Reference
- src/gamemaster_mcp/main.py:561-589 (handler)MCP tool handler for 'update_game_state'. Defines input schema via Annotated parameters with Field descriptions and constraints. 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" - Storage class method that implements the actual game state update logic by dynamically setting attributes on the GameState object based on kwargs, updating timestamps, and persisting to file.
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()