load_campaign
Utilize this tool to load a specific Dungeons & Dragons campaign into the MCP server, enabling efficient management of characters, quests, and session tracking. Specify the campaign name to initiate the process.
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:113-119 (handler)The primary MCP tool handler for 'load_campaign'. Decorated with @mcp.tool for registration, includes input schema via Annotated Field, executes by calling storage.load_campaign(name) and returns confirmation message.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!"
- Core helper method in DnDStorage class that performs the actual campaign loading: computes file path, reads JSON, validates with Pydantic Campaign model, sets as active 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