Skip to main content
Glama

get_sessions

Retrieve all session notes to track campaign progress and reference past events in Dungeons & Dragons 5e games.

Instructions

Get all session notes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implementation of the 'get_session_state' tool. Note: In the code, the function name is 'get_session_state', but it corresponds to the 'get_sessions' entry in the permissions registry.
    async def get_session_state(
        session_id: str,
        detail_level: str = "standard",
        include_history: bool = True,
        history_limit: int = 10,
    ) -> dict:
        """
        Get the current state of a Claudmaster session.
    
        This MCP tool queries the state of an active session, returning
        information about the game state, party, recent history, and
        session metadata. Supports multiple detail levels.
    
        Args:
            session_id: The session ID to query
            detail_level: How much detail to include:
                - "minimal": Basic session info and status only
                - "standard": Session info, game state, party status, recent history
                - "full": Everything including complete context budget analysis
            include_history: Whether to include action history in the response
            history_limit: Maximum number of history entries to return (default: 10)
    
        Returns:
            Dictionary with the following keys:
                - session_info: Basic session metadata (id, status, campaign, duration)
                - game_state: Current game state (location, combat, turn count)
                - party_status: List of character summaries with status
                - recent_history: Last N actions (if include_history=True)
                - active_quests: Current quest status (placeholder)
                - context_usage: Context window utilization info
                - error_message: Error description if session not found
    
        Examples:
            Get standard session state:
            >>> result = await get_session_state(session_id="abc123")
    
            Get minimal info (fast):
            >>> result = await get_session_state(
            ...     session_id="abc123",
            ...     detail_level="minimal"
            ... )
    
            Get full state with extended history:
            >>> result = await get_session_state(
            ...     session_id="abc123",
            ...     detail_level="full",
            ...     history_limit=50
            ... )
        """
        try:
            # Validate detail level
            valid_levels = ("minimal", "standard", "full")
            if detail_level not in valid_levels:
                return {
                    "error_message": (
                        f"*The DM adjusts their spectacles*\n\n"
                        f"I don't recognize the '{detail_level}' level of detail. "
                        f"Please choose from: {', '.join(valid_levels)}."
                    )
                }
    
            # Get session state from manager
            state = _session_manager.get_session_state(session_id)
    
            if state is None:
                return {
                    "error_message": _error_formatter.format_session_not_found(session_id)
                }
    
            # Get raw session for additional details
            orchestrator, session = _session_manager._active_sessions[session_id]
    
            # Calculate duration
            duration_minutes = int((datetime.now() - session.started_at).total_seconds() / 60)
    
            # Build session_info (always included)
            session_info = {
                "session_id": state.session_id,
                "status": state.status,
                "campaign_id": state.campaign_info.campaign_id,
                "campaign_name": state.campaign_info.campaign_name,
                "duration_minutes": duration_minutes,
                "turn_count": session.turn_count,
            }
    
            # Minimal level: just session info
            if detail_level == "minimal":
                return {"session_info": session_info}
    
            # Standard and full: add game state and party
            game_state = state.game_state.model_dump()
            party_status = [char.model_dump() for char in state.party_info]
    
            # Build history if requested
            recent_history: list[dict] = []
            if include_history:
                limit = history_limit if detail_level == "standard" else max(history_limit, 50)
                for msg in session.conversation_history[-limit:]:
                    recent_history.append(msg)
    
            # Context usage
            context_usage = {
                "context_budget_remaining": state.context_budget,
                "max_tokens": session.config.max_tokens,
            }
    
            # Full level: add extra detail
            if detail_level == "full":
                context_usage["conversation_length"] = len(session.conversation_history)
                context_usage["active_agents"] = dict(session.active_agents)
    
            # Build active quests from campaign data
            active_quests = []
            if _storage:
                campaign = _storage.get_current_campaign()
                if campaign:
                    active_quests = [
                        {"title": quest.title, "status": quest.status, "giver": quest.giver}
                        for quest in campaign.quests.values()
                        if quest.status == "active"
                    ]
    
            return {
                "session_info": session_info,
                "game_state": game_state,
                "party_status": party_status,
                "recent_history": recent_history,
                "active_quests": active_quests,
                "context_usage": context_usage,
            }
    
        except Exception as e:
            logger.error(f"Error in get_session_state for {session_id}: {e}", exc_info=True)
            return {
                "error_message": _error_formatter.format_error(e)
            }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Get all session notes' implies a read-only operation, but it doesn't specify permissions required, rate limits, pagination behavior, or what happens if no notes exist (e.g., returns empty list or error). For a tool with zero annotation coverage, this lack of behavioral detail is a significant gap, making it hard for an agent to predict outcomes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description 'Get all session notes' is a single, front-loaded sentence with zero waste. It efficiently conveys the core action and resource without unnecessary words. Given the simplicity of the tool (no parameters), this conciseness is appropriate and effective.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is minimally complete but lacks important context. It doesn't explain what 'session notes' are (e.g., text entries, metadata), how they are returned (e.g., list format, JSON structure), or any behavioral aspects like error handling. Without annotations or output schema, the description should provide more detail to be fully helpful for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add any parameter information, which is acceptable here since there are no parameters to explain. A baseline score of 4 is appropriate as the schema fully covers the absence of parameters, and the description doesn't need to compensate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get all session notes' clearly states the verb ('Get') and resource ('session notes'), making the purpose understandable. However, it's somewhat vague about scope—'all' implies no filtering, but it doesn't specify if this includes archived or deleted notes, or how notes are structured. It distinguishes from siblings like 'add_session_note' by being a read operation, but lacks detail on what constitutes a 'session note' in this context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. For example, it doesn't mention if there are other tools for filtered or paginated retrieval of session notes, or if this is the primary method for accessing notes. With siblings like 'get_events' or 'summarize_session', there's no indication of how this tool fits into the workflow, leaving usage context unclear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/Polloinfilzato/dm20-protocol'

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