Skip to main content
Glama

get_events

Retrieve and filter events from the adventure log by type, keyword, or limit, aiding in Dungeons & Dragons campaign tracking and session management.

Instructions

Get events from the adventure log.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
event_typeNoFilter by event type
limitNoMaximum number of events to return
searchNoSearch events by title/description

Implementation Reference

  • MCP tool handler and registration for 'get_events'. Fetches events from storage (filtered by limit, event_type, or search), formats them into a markdown list, and returns as string.
    def get_events( limit: Annotated[int | None, Field(description="Maximum number of events to return", ge=1)] = None, event_type: Annotated[Literal["combat", "roleplay", "exploration", "quest", "character", "world", "session"] | None, Field(description="Filter by event type")] = None, search: Annotated[str | None, Field(description="Search events by title/description")] = None, ) -> str: """Get events from the adventure log.""" if search: events = storage.search_events(search) else: events = storage.get_events(limit=limit, event_type=event_type) if not events: return "No events found." event_list = [] for event in events: timestamp = event.timestamp.strftime("%Y-%m-%d %H:%M") session_text = f" (Session {event.session_number})" if event.session_number else "" importance_stars = "★" * event.importance event_list.append(f"**{event.title}** [{event.event_type}] {importance_stars}") event_list.append(f" {timestamp}{session_text}") event_list.append(f" {event.description[:150]}{'...' if len(event.description) > 150 else ''}") if event.location: event_list.append(f" 📍 {event.location}") event_list.append("") return "**Adventure Log:**\n\n" + "\n".join(event_list)
  • DnDStorage helper method that retrieves adventure events, optionally filtered by event_type and limited by count, sorted newest first.
    def get_events(self, limit: int | None = None, event_type: str | None = None) -> list[AdventureEvent]: """Get adventure events, optionally filtered.""" events = self._events if event_type: events = [e for e in events if e.event_type == event_type] # Sort by timestamp (newest first) events = sorted(events, key=lambda e: e.timestamp, reverse=True) if limit: events = events[:limit] return events
  • DnDStorage helper method for searching events by query in title or description, used when 'search' parameter is provided in the tool.
    def search_events(self, query: str) -> list[AdventureEvent]: """Search events by title or description.""" query_lower = query.lower() return [ event for event in self._events if query_lower in event.title.lower() or query_lower in event.description.lower() ]
  • Input schema validation using Pydantic Annotated types and Field descriptions for the get_events tool parameters.
    limit: Annotated[int | None, Field(description="Maximum number of events to return", ge=1)] = None, event_type: Annotated[Literal["combat", "roleplay", "exploration", "quest", "character", "world", "session"] | None, Field(description="Filter by event type")] = None, search: Annotated[str | None, Field(description="Search events by title/description")] = None, ) -> str: """Get events from the adventure log.""" if search: events = storage.search_events(search) else: events = storage.get_events(limit=limit, event_type=event_type) if not events: return "No events found." event_list = [] for event in events: timestamp = event.timestamp.strftime("%Y-%m-%d %H:%M") session_text = f" (Session {event.session_number})" if event.session_number else "" importance_stars = "★" * event.importance event_list.append(f"**{event.title}** [{event.event_type}] {importance_stars}") event_list.append(f" {timestamp}{session_text}") event_list.append(f" {event.description[:150]}{'...' if len(event.description) > 150 else ''}") if event.location: event_list.append(f" 📍 {event.location}") event_list.append("") return "**Adventure Log:**\n\n" + "\n".join(event_list)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/study-flamingo/gamemaster-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server