get_sessions
Retrieve all session notes to track campaign progress and maintain continuity in Dungeons & Dragons adventures.
Instructions
Get all session notes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gamemaster_mcp/main.py:698-713 (handler)The MCP tool handler for 'get_sessions'. Decorated with @mcp.tool, it retrieves session notes from storage, formats them into a markdown-formatted string list sorted by session number, and returns it. This is both the handler logic and registration point.@mcp.tool def get_sessions() -> str: """Get all session notes.""" sessions = storage.get_sessions() if not sessions: return "No session notes recorded." session_list = [] for session in sorted(sessions, key=lambda s: s.session_number): title = session.title or "No title" date = session.date.strftime("%Y-%m-%d") session_list.append(f"**Session {session.session_number}** ({date}): {title}") session_list.append(f" {session.summary[:100]}{'...' if len(session.summary) > 100 else ''}") session_list.append("") return "**Session Notes:**\n\n" + "\n".join(session_list)
- Core helper method in the Storage class that returns the list of SessionNote objects from the current campaign's sessions attribute.def get_sessions(self) -> list[SessionNote]: """Get all session notes.""" if not self._current_campaign: return [] return self._current_campaign.sessions
- src/gamemaster_mcp/models.py:330-342 (schema)Pydantic model defining the structure of each SessionNote object returned by the storage helper and used in the tool handler.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 = ""