Skip to main content
Glama

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
NameRequiredDescriptionDefault
current_date_in_gameNoCurrent in-game date
current_locationNoCurrent party location
current_sessionNoCurrent session number
in_combatNoWhether party is in combat
notesNoCurrent situation notes
party_fundsNoParty treasure/funds
party_levelNoAverage party level

Implementation Reference

  • 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()
  • 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"

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