Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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
  • 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
  • The @mcp.tool decorator registers the get_game_state function as an MCP tool.
    @mcp.tool

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