Skip to main content
Glama

end_claudmaster_session

End or pause a Dungeons & Dragons AI game session, saving all state and campaign data for later continuation or termination.

Instructions

End or pause a Claudmaster AI DM session, saving all state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesThe session ID to end or pause
modeNo'pause' to save for later, 'end' for final terminationpause
summary_notesNoOptional DM notes to save with the session
campaign_pathNoOptional path for disk persistence

Implementation Reference

  • The 'end_session' tool (MCP tool) implementation, which ends or pauses a Claudmaster AI DM session and persists its state. Note: The tool name is 'end_session', and it corresponds to the permission 'end_claudmaster_session' registered in 'permissions.py'.
    async def end_session(
        session_id: str,
        mode: str = "pause",
        summary_notes: Optional[str] = None,
        campaign_path: Optional[str] = None,
    ) -> dict:
        """
        End or pause a Claudmaster session, saving all state.
    
        This MCP tool cleanly terminates or pauses a Claudmaster session.
        In "pause" mode, all state is persisted to disk so the session can
        be resumed later. In "end" mode, state is saved as a final snapshot
        and the session is terminated.
    
        Args:
            session_id: The session ID to end or pause
            mode: "pause" (save for later resumption) or "end" (final termination)
            summary_notes: Optional DM notes to save with the session snapshot
            campaign_path: Optional path for disk persistence.
                If provided, session state is written to disk under this path.
    
        Returns:
            Dictionary with the following keys:
                - status: "paused" or "ended" on success, "error" on failure
                - session_id: The session ID that was ended
                - session_summary: Brief summary of the session
                - save_path: Where state was persisted (if campaign_path provided)
                - stats: Session statistics (duration, turn count, etc.)
                - error_message: Error description if status is "error"
    
        Examples:
            Pause a session for later:
            >>> result = await end_session(
            ...     session_id="abc123",
            ...     mode="pause",
            ...     summary_notes="Party just entered the dungeon"
            ... )
    
            End a session permanently:
            >>> result = await end_session(session_id="abc123", mode="end")
    
            Pause with disk persistence:
            >>> result = await end_session(
            ...     session_id="abc123",
            ...     mode="pause",
            ...     campaign_path="/data/campaigns/my-campaign"
            ... )
        """
        try:
            # Validate mode
            if mode not in ("pause", "end"):
                return {
                    "status": "error",
                    "session_id": session_id,
                    "error_message": f"*The DM tilts their head, puzzled*\n\nI'm not familiar with the '{mode}' command. When ending a session, please choose either 'pause' (to resume later) or 'end' (to conclude permanently).",
                }
    
            # Check session exists
            if session_id not in _session_manager._active_sessions:
                return {
                    "status": "error",
                    "session_id": session_id,
                    "error_message": _error_formatter.format_session_not_found(session_id),
                }
    
            # Get session info before ending
            orchestrator, session = _session_manager._active_sessions[session_id]
            turn_count = session.turn_count
            started_at = session.started_at
            campaign_id = session.campaign_id
    
            # Calculate duration
            duration_minutes = int((datetime.now() - started_at).total_seconds() / 60)
    
            # Build stats
            stats = {
                "turn_count": turn_count,
                "duration_minutes": duration_minutes,
                "started_at": started_at.isoformat(),
                "ended_at": datetime.now().isoformat(),
            }
    
            # Save to memory first (for resume capability)
            _session_manager.save_session(session_id)
    
            # Persist to disk if campaign_path provided
            save_path = None
            if campaign_path:
                serializer = SessionSerializer(Path(campaign_path))
                saved_data = _session_manager._saved_sessions.get(session_id, {})
                save_dir = serializer.save_session(
                    session_data=saved_data,
                    mode=mode,
                    summary_notes=summary_notes,
                )
                save_path = str(save_dir)
    
            # End the session (removes from active)
            result_status = "paused" if mode == "pause" else "ended"
            _session_manager.end_session(session_id)
    
            # Build summary
            session_summary = (
                f"Session {session_id} for campaign '{campaign_id}': "
                f"{turn_count} turns over {duration_minutes} minutes."
            )
    
            logger.info(f"MCP end_session: {result_status} session {session_id}")
    
            return {
                "status": result_status,
                "session_id": session_id,
                "session_summary": session_summary,
                "save_path": save_path,
                "stats": stats,
            }
    
        except Exception as e:
            logger.error(f"Error in end_session for {session_id}: {e}", exc_info=True)
            return {
                "status": "error",
                "session_id": session_id,
                "error_message": _error_formatter.format_error(e),
            }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions state saving, which is useful, but doesn't cover critical aspects like whether this operation is reversible, what permissions are needed, if it affects other sessions, or what the response looks like. For a session termination/pausing tool, this leaves significant behavioral gaps.

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 is a single, efficient sentence that front-loads the core action and outcome. Every word contributes meaning with zero waste, making it appropriately sized for the tool's complexity.

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

Completeness3/5

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

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is minimally adequate. It states what the tool does but lacks details on behavioral implications, error conditions, or return values. The high schema coverage helps, but for a session management tool with mutation effects, more context would be beneficial.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions, such as explaining the implications of choosing 'pause' vs 'end' modes. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb ('end or pause') and resource ('Claudmaster AI DM session'), and specifies the outcome ('saving all state'). It distinguishes from sibling tools like 'start_claudmaster_session' by indicating termination/pausing rather than initiation, though it doesn't explicitly contrast with other session management tools.

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?

No guidance is provided on when to use this tool versus alternatives. While it's implied to be used after starting a session with 'start_claudmaster_session', there's no mention of prerequisites, timing considerations, or what happens if used incorrectly. The description lacks explicit usage context or exclusions.

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