add_event
Log events in your Dungeons & Dragons campaign with details like type, title, description, session number, characters involved, location, importance, and tags for better tracking.
Instructions
Add an event to the adventure log.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| characters_involved | No | Characters involved in the event | |
| description | Yes | Event description | |
| event_type | Yes | Type of event | |
| importance | No | Event importance (1-5) | |
| location | No | Location where event occurred | |
| session_number | No | Session number | |
| tags | No | Tags for categorizing the event | |
| title | Yes | Event title |
Implementation Reference
- src/gamemaster_mcp/main.py:716-740 (handler)The main tool handler: @mcp.tool-decorated function that parses input parameters, constructs an AdventureEvent object, and calls the storage layer to persist it. This is the primary implementation of the 'add_event' MCP tool.@mcp.tool def add_event( event_type: Annotated[Literal["combat", "roleplay", "exploration", "quest", "character", "world", "session"], Field(description="Type of event")], title: Annotated[str, Field(description="Event title")], description: Annotated[str, Field(description="Event description")], session_number: Annotated[int | None, Field(description="Session number", ge=1)] = None, characters_involved: Annotated[list[str] | None, Field(description="Characters involved in the event")] = None, location: Annotated[str | None, Field(description="Location where event occurred")] = None, importance: Annotated[int, Field(description="Event importance (1-5)", ge=1, le=5)] = 3, tags: Annotated[list[str] | None, Field(description="Tags for categorizing the event")] = None, ) -> str: """Add an event to the adventure log.""" event = AdventureEvent( event_type=EventType(event_type), title=title, description=description, session_number=session_number, characters_involved=characters_involved or [], location=location, importance=importance, tags=tags or [] ) storage.add_event(event) return f"Added {event_type.lower} event: '{event.title}'"
- src/gamemaster_mcp/models.py:405-416 (schema)Pydantic model defining the structure and validation for AdventureEvent objects used by the add_event tool.class AdventureEvent(BaseModel): """Individual event in the adventure log.""" id: str = Field(default_factory=lambda: random(length=8)) event_type: EventType title: str description: str timestamp: datetime = Field(default_factory=datetime.now) session_number: int | None = None characters_involved: list[str] = Field(default_factory=list) location: str | None = None tags: list[str] = Field(default_factory=list) importance: int = Field(ge=1, le=5, default=3) # 1=minor, 5=major
- src/gamemaster_mcp/models.py:395-402 (schema)Enum defining valid event types for the add_event tool input.class EventType(str, Enum): COMBAT = "combat" ROLEPLAY = "roleplay" EXPLORATION = "exploration" QUEST = "quest" CHARACTER = "character" WORLD = "world" SESSION = "session"
- Helper method in DnDStorage class that appends the event to the in-memory event list and triggers persistence to JSON file.def add_event(self, event: AdventureEvent) -> None: """Add an event to the adventure log.""" logger.info(f"➕ Adding event: '{event.title}' ({event.event_type})") self._events.append(event) self._save_events() logger.debug("✅ Event added and log saved.")
- src/gamemaster_mcp/main.py:716-716 (registration)The @mcp.tool decorator registers the add_event function as an MCP tool.@mcp.tool