create_campaign
Create a new Dungeons & Dragons campaign by specifying its name, description, Dungeon Master, and setting details for campaign management.
Instructions
Create a new D&D campaign.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Campaign name | |
| description | Yes | Brief decription of the campaign, or a tagline | |
| dm_name | No | Dungeon Master name | |
| setting | No | Campaign setting - a full description of the setting of the campaign in markdown format, or the path to a `.txt` or `.md` file containing the same. |
Implementation Reference
- src/gamemaster_mcp/main.py:51-67 (handler)MCP tool handler for 'create_campaign'. Registers the tool via @mcp.tool decorator and implements the tool logic by delegating to storage.create_campaign, returning a success message.@mcp.tool def create_campaign( name: Annotated[str, Field(description="Campaign name")], description: Annotated[str, Field(description="Brief decription of the campaign, or a tagline")], dm_name: Annotated[str | None, Field(description="Dungeon Master name")] = None, setting: Annotated[str | Path | None, Field(description=""" Campaign setting - a full description of the setting of the campaign in markdown format, or the path to a `.txt` or `.md` file containing the same. """)] = None, ) -> str: """Create a new D&D campaign.""" campaign = storage.create_campaign( name=name, description=description, dm_name=dm_name, setting=setting ) return f"🌟 Created campaign: '{campaign.name} and set as active 🌟'"
- Core helper function in storage layer that instantiates a new Campaign model, initializes GameState, sets it as the current campaign, persists to JSON file, and returns the Campaign object.def create_campaign(self, name: str, description: str, dm_name: str | None = None, setting: str | Path | None = None) -> Campaign: """Create a new campaign.""" logger.info(f"✨ Creating new campaign: '{name}'") game_state = GameState(campaign_name=name) campaign = Campaign( name=name, description=description, dm_name=dm_name, setting=setting, game_state=game_state ) self._current_campaign = campaign self._save_campaign() logger.info(f"✅ Campaign '{name}' created and set as active.") return campaign
- src/gamemaster_mcp/main.py:51-51 (registration)The @mcp.tool decorator registers the create_campaign function as an MCP tool.@mcp.tool