Skip to main content
Glama

delete_campaign

Permanently remove a campaign from the DM20 Protocol server. This action deletes all associated data and cannot be reversed.

Instructions

Delete a campaign permanently. This cannot be undone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesCampaign name to delete

Implementation Reference

  • The `delete_campaign` method within `DnDStorage` class handles the deletion of campaigns by detecting the storage format (monolithic vs split) and removing the corresponding file or directory, and resetting the active campaign state if necessary.
    def delete_campaign(self, name: str) -> str:
        """Delete a campaign from storage.
    
        Supports both monolithic (single JSON file) and split (directory) formats.
        If the deleted campaign is the currently active one, all state is cleared.
    
        Args:
            name: The name of the campaign to delete
    
        Returns:
            The name of the deleted campaign
    
        Raises:
            FileNotFoundError: If the campaign does not exist
        """
        storage_format = self._detect_campaign_format(name)
    
        if storage_format == StorageFormat.NOT_FOUND:
            raise FileNotFoundError(f"Campaign '{name}' not found")
    
        safe_name = "".join(c for c in name if c.isalnum() or c in (' ', '-', '_', "'")).rstrip()
    
        if storage_format == StorageFormat.MONOLITHIC:
            file_path = self._get_campaign_file(name)
            file_path.unlink()
            logger.info(f"๐Ÿ—‘๏ธ Deleted monolithic campaign file: {file_path}")
        elif storage_format == StorageFormat.SPLIT:
            dir_path = self.data_dir / "campaigns" / safe_name
            # Safety check: path must be under campaigns directory
            campaigns_dir = (self.data_dir / "campaigns").resolve()
            if not dir_path.resolve().is_relative_to(campaigns_dir):
                raise ValueError(f"Unsafe path detected: {dir_path}")
            try:
                shutil.rmtree(dir_path)
            except OSError:
                # Retry: macOS race condition with file watchers / .DS_Store
                import time
                time.sleep(0.3)
                shutil.rmtree(dir_path)
            logger.info(f"๐Ÿ—‘๏ธ Deleted split campaign directory: {dir_path}")
    
        # If deleting the active campaign, clear all state
        if self._current_campaign and self._current_campaign.name == name:
            self._current_campaign = None
            self._current_format = StorageFormat.NOT_FOUND
            self._character_id_index.clear()
            self._player_name_index.clear()
            self._campaign_hash = ""
            self._rulebook_manager = None
            self._rules_version = "2024"
            self._interaction_mode = "classic"
            self._library_bindings = None
            self._discovery_tracker = None
            if hasattr(self, '_split_backend'):
                self._split_backend._current_campaign = None
            logger.info(f"๐Ÿงน Cleared active campaign state (was: '{name}')")
    
        return name
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates that the operation is irreversible and destructive ('permanently,' 'cannot be undone'), which is critical for a deletion tool. However, it does not mention potential side effects, permissions required, or error conditions, leaving some behavioral aspects uncovered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise and front-loaded, consisting of two short sentences that convey the essential information without any wasted words. It directly addresses the tool's core functionality and critical warning, making it efficient and easy to parse for an AI agent.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with no annotations and no output schema, the description provides basic but incomplete context. It covers the irreversible nature of the action but lacks details on success/failure responses, error handling, or integration with sibling tools like 'list_campaigns.' Given the tool's complexity and missing structured data, more comprehensive guidance would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the parameter 'name' clearly documented as 'Campaign name to delete.' The description does not add any additional semantic context beyond this, such as format examples or validation rules. Given the high schema coverage, a baseline score of 3 is appropriate, as the schema adequately handles parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and resource ('a campaign'), with the adverb 'permanently' emphasizing the nature of the operation. It distinguishes itself from siblings like 'list_campaigns' or 'get_campaign_info' by specifying a destructive write action, making the purpose explicit and unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through 'permanently' and 'cannot be undone,' suggesting caution, but does not explicitly state when to use this tool versus alternatives like 'delete_character' or prerequisites. It lacks direct guidance on scenarios or comparisons with sibling tools, leaving usage somewhat inferred rather than clearly defined.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Polloinfilzato/dm20-protocol'

If you have feedback or need assistance with the MCP directory API, please join our Discord server