Skip to main content
Glama
study-flamingo

D&D MCP Server

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
NameRequiredDescriptionDefault
nameYesCampaign name
descriptionYesBrief decription of the campaign, or a tagline
dm_nameNoDungeon Master name
settingNo 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

  • 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
  • The @mcp.tool decorator registers the create_campaign 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