enable_library_source
Add library content to campaigns by enabling entire sources or filtering by type and specific items like classes, spells, or monsters.
Instructions
Enable a library source for the current campaign.
Adds a library source to the campaign's enabled content. You can enable the entire source or filter by content type and specific items.
Examples: - enable_library_source("tome-of-heroes") - Enable all content - enable_library_source("tome-of-heroes", content_type="class") - Enable all classes - enable_library_source("tome-of-heroes", content_type="class", content_names=["dragon-knight"]) - Enable specific class
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_id | Yes | The source identifier (e.g., 'tome-of-heroes') | |
| content_type | No | Filter by content type. Use 'all' or omit to enable entire source. | all |
| content_names | No | Specific content names to enable (e.g., ['dragon-knight', 'shadow-dancer']). Only used if content_type is specified. |
Implementation Reference
- src/dm20_protocol/storage.py:1286-1323 (handler)The enable_library_source function is implemented in the DnDStorage class in src/dm20_protocol/storage.py. It validates that a campaign and library bindings exist, and updates the library bindings to enable the specified source.
def enable_library_source( self, source_id: str, content_type: str | None = None, content_names: list[str] | None = None, ) -> None: """Enable a library source for the current campaign. Args: source_id: The source identifier to enable content_type: Optional content type to filter (e.g., "class", "spell"). If None, enables all content from the source. content_names: Optional list of specific content names to enable. Only used if content_type is specified. """ if not self._current_campaign: raise ValueError("No current campaign") if not self._library_bindings: raise ValueError("Library bindings not initialized") # Convert string content_type to ContentType enum if provided from .library.models import ContentType content_type_enum = None if content_type and content_type != "all": try: content_type_enum = ContentType(content_type) except ValueError: raise ValueError(f"Invalid content type: {content_type}") self._library_bindings.enable_source( source_id=source_id, content_type=content_type_enum, content_names=content_names, ) self._save_library_bindings() logger.info(f"✅ Enabled library source '{source_id}' for campaign '{self._current_campaign.name}'")