add_session_note
Track and organize Dungeons & Dragons session details by adding notes, including summaries, key events, characters present, experience gained, and treasure found, ensuring comprehensive campaign management.
Instructions
Add notes for a game session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| characters_present | No | Characters present in session | |
| events | No | Key events that occurred | |
| experience_gained | No | Experience points gained | |
| notes | No | Additional notes | |
| session_number | Yes | Session number | |
| summary | Yes | Session summary | |
| title | No | Session title | |
| treasure_found | No | Treasure or items found |
Implementation Reference
- src/gamemaster_mcp/main.py:672-696 (handler)The primary handler function for the 'add_session_note' MCP tool, decorated with @mcp.tool for automatic registration. Defines input schema via Annotated parameters with Pydantic Field descriptions and constraints. Implements logic by instantiating SessionNote model and persisting via storage.@mcp.tool def add_session_note( session_number: Annotated[int, Field(description="Session number", ge=1)], summary: Annotated[str, Field(description="Session summary")], title: Annotated[str | None, Field(description="Session title")] = None, events: Annotated[list[str] | None, Field(description="Key events that occurred")] = None, characters_present: Annotated[list[str] | None, Field(description="Characters present in session")] = None, experience_gained: Annotated[int | None, Field(description="Experience points gained", ge=0)] = None, treasure_found: Annotated[list[str] | None, Field(description="Treasure or items found")] = None, notes: Annotated[str, Field(description="Additional notes")] = "", ) -> str: """Add notes for a game session.""" session_note = SessionNote( session_number=session_number, title=title, summary=summary, events=events or [], characters_present=characters_present or [], experience_gained=experience_gained, treasure_found=treasure_found or [], notes=notes ) storage.add_session_note(session_note) return f"Added session note for Session {session_note.session_number}"
- src/gamemaster_mcp/models.py:330-341 (schema)Pydantic BaseModel defining the SessionNote data structure, which matches the tool's input parameters. Provides validation and serialization for session notes.class SessionNote(BaseModel): """Session notes and summary.""" id: str = Field(default_factory=lambda: random(length=8)) session_number: int date: datetime = Field(default_factory=datetime.now) title: str | None = None summary: str events: list[str] = Field(default_factory=list) characters_present: list[str] = Field(default_factory=list) experience_gained: int | None = None treasure_found: list[str] = Field(default_factory=list) notes: str = ""
- Helper method in the DnDStorage class that appends the provided SessionNote to the current campaign's sessions list, updates timestamps, and persists the campaign data to storage.def add_session_note(self, session_note: SessionNote) -> None: """Add a session note.""" if not self._current_campaign: raise ValueError("No current campaign") self._current_campaign.sessions.append(session_note) self._current_campaign.updated_at = datetime.now() self._save_campaign()