create_campaign
Initiate a new Dungeons & Dragons campaign by defining its name, description, Dungeon Master, and setting. Simplifies campaign creation for organized gameplay and storytelling.
Instructions
Create a new D&D campaign.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes | Brief decription of the campaign, or a tagline | |
| dm_name | No | Dungeon Master name | |
| name | Yes | Campaign 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: validates input via Annotated fields (serving as schema), calls storage layer, and returns formatted 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 logic for instantiating Campaign model, setting as current, and persisting to JSON file.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)FastMCP decorator registering the create_campaign function as a tool.@mcp.tool