load_campaign
Load a specific Dungeons & Dragons campaign by name to access its characters, NPCs, locations, quests, and session data for campaign management.
Instructions
Load a specific campaign.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Campaign name to load |
Implementation Reference
- src/gamemaster_mcp/main.py:112-118 (handler)MCP tool handler for 'load_campaign'. Takes campaign name, loads it via storage, sets as current, and returns confirmation message.@mcp.tool def load_campaign( name: Annotated[str, Field(description="Campaign name to load")] ) -> str: """Load a specific campaign.""" campaign = storage.load_campaign(name) return f"📖 Loaded campaign: '{campaign.name}'. Campaign is now active!"
- Helper method in Storage class that loads the campaign JSON file, validates with Pydantic Campaign model, sets as current campaign, and returns it.def load_campaign(self, name: str) -> Campaign: """Load a specific campaign.""" logger.info(f"📂 Attempting to load campaign: '{name}'") campaign_file = self._get_campaign_file(name) logger.debug(f"📂 Campaign file path: {campaign_file}") if not campaign_file.exists(): logger.error(f"❌ Campaign file not found for '{name}'") raise FileNotFoundError(f"Campaign '{name}' not found") with open(campaign_file, 'r', encoding='utf-8') as f: data = json.load(f) self._current_campaign = Campaign.model_validate(data) logger.info(f"✅ Successfully loaded campaign '{name}'.") return self._current_campaign
- src/gamemaster_mcp/main.py:114-114 (schema)Input schema for the tool: campaign name as string with description.name: Annotated[str, Field(description="Campaign name to load")]