get_sessions
Retrieve all session notes for Dungeons & Dragons campaigns from the D&D MCP Server to manage and track campaign progress effectively.
Instructions
Get all session notes.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/gamemaster_mcp/main.py:698-713 (registration)Registration and handler function for the 'get_sessions' MCP tool. Decorated with @mcp.tool, it retrieves session notes via storage.get_sessions() and formats a markdown string response listing all sessions.@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)
- src/gamemaster_mcp/main.py:698-713 (handler)The main execution logic for the 'get_sessions' tool, formatting and returning session notes as a string.@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)
- Storage helper method that returns the list of SessionNote objects from the current campaign's sessions.def get_sessions(self) -> list[SessionNote]: """Get all session notes.""" if not self._current_campaign: return [] return self._current_campaign.sessions