Skip to main content
Glama

sessions_step_out

Step out of the current function during debugging to return to the calling code, requiring an active breakpoint and session ID.

Instructions

Step out of the current function (requires active breakpoint)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesThe debug session ID

Implementation Reference

  • Registers the 'sessions_step_out' tool with the MCP SDK, defining its name, description, and input schema requiring 'sessionId'.
    Tool(
        name="sessions_step_out",
        description="Step out of the current function (requires active breakpoint)",
        inputSchema={
            "type": "object",
            "properties": {
                "sessionId": {
                    "type": "string",
                    "description": "The debug session ID",
                },
            },
            "required": ["sessionId"],
        },
    ),
  • MCP tool handler: validates sessionId, calls SessionManager.step_out_async, serializes and returns response as TextContent or error.
    async def _handle_sessions_step_out(self, arguments: dict) -> list[TextContent]:
        """
        Handler for sessions_step_out tool.
        
        Steps out of the current function.
        """
        try:
            session_id = arguments.get("sessionId")
            if not session_id:
                return [
                    TextContent(
                        type="text",
                        text=json.dumps({
                            "error": {
                                "type": "ValueError",
                                "message": "sessionId is required",
                            }
                        }),
                    )
                ]
    
            response = await self.session_manager.step_out_async(session_id)
            result = response.model_dump()
    
            return [
                TextContent(
                    type="text",
                    text=json.dumps(result),
                )
            ]
        except KeyError as e:
            return [
                TextContent(
                    type="text",
                    text=json.dumps({
                        "error": {
                            "type": "SessionNotFound",
                            "message": str(e),
                        }
                    }),
                )
            ]
        except Exception as e:
            logger.exception("Error in step_out")
            return [
                TextContent(
                    type="text",
                    text=json.dumps({
                        "error": {
                            "type": type(e).__name__,
                            "message": str(e),
                        }
                    }),
                )
            ]
  • Core step-out logic in SessionManager: validates DAP session and PAUSED state, calls DAP wrapper's step_out, updates session state and timings.
    def step_out(self, session_id: str) -> BreakpointResponse:
        """
        Step out of the current function (DAP only).
        
        Args:
            session_id: Session ID
            
        Returns:
            BreakpointResponse with new location and variables
            
        Raises:
            KeyError: If session not found
            ValueError: If session is not using DAP
        """
        session = self.get_session(session_id)
    
        if not session.use_dap:
            return BreakpointResponse(
                hit=False,
                completed=False,
                error=ExecutionError(
                    type="NotImplementedError",
                    message="Step operations require DAP integration (set useDap=true when creating session)",
                ),
            )
    
        if not session.dap_wrapper:
            return BreakpointResponse(
                hit=False,
                completed=False,
                error=ExecutionError(
                    type="SessionError",
                    message="DAP session not initialized",
                ),
            )
    
        if session.status != SessionStatus.PAUSED:
            return BreakpointResponse(
                hit=False,
                completed=False,
                error=ExecutionError(
                    type="InvalidStateError",
                    message=f"Cannot step from state: {session.status}. Must be PAUSED.",
                ),
            )
    
        session.update_status(SessionStatus.RUNNING)
    
        with Timer() as timer:
            try:
                response = session.dap_wrapper.step_out(timeout=DEFAULT_TIMEOUT_SECONDS)
    
                # Update session state
                if response.hit:
                    session.update_status(SessionStatus.PAUSED)
                    if response.frameInfo:
                        session.update_breakpoint(response.frameInfo.file, response.frameInfo.line)
                elif response.completed:
                    session.update_status(SessionStatus.COMPLETED)
                elif response.error:
                    session.update_status(SessionStatus.ERROR)
    
                session.update_timings(timer.elapsed_ms)
                return response
    
            except Exception as e:
                session.update_status(SessionStatus.ERROR)
                return BreakpointResponse(
                    hit=False,
                    completed=False,
                    error=ExecutionError(
                        type=type(e).__name__,
                        message=str(e),
                    ),
                )
  • Async wrapper that runs the synchronous step_out method in a thread pool for non-blocking MCP handler calls.
    async def step_out_async(self, session_id: str) -> BreakpointResponse:
        """
        Async wrapper for step_out.
        
        Runs the synchronous step_out in a thread pool to avoid blocking.
        """
        return await asyncio.to_thread(self.step_out, session_id)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the requirement of an 'active breakpoint', which adds useful context about preconditions. However, it lacks details on what 'step out' entails (e.g., does it exit to the caller, affect session state, or have side effects?), making it insufficient for a mutation tool in debugging.

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 ('step out of the current function') and includes a crucial precondition ('requires active breakpoint') without any wasted words. Every part earns its place by providing essential information concisely.

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 complexity (a debugging operation with mutation implications), no annotations, and no output schema, the description is minimally adequate. It covers the purpose and a key precondition but lacks details on behavior, error cases, or return values, leaving gaps for an agent to understand full usage.

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?

The input schema has 100% description coverage, with the parameter 'sessionId' documented as 'The debug session ID'. The description does not add any meaning beyond this, as it doesn't explain parameter usage or constraints. Baseline score of 3 is appropriate since the schema handles the parameter documentation adequately.

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 action ('step out of') and the context ('current function'), which is a specific debugging operation. It distinguishes from siblings like 'step_in' and 'step_over' by implying movement out of a function rather than into or over lines. However, it doesn't explicitly name the resource (e.g., debug session) beyond the parameter, keeping it from a perfect score.

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

Usage Guidelines3/5

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

The description provides implied usage context by stating 'requires active breakpoint', which suggests when to use this tool (during debugging with a breakpoint set). However, it doesn't explicitly differentiate when to use this vs. alternatives like 'sessions_continue' or 'sessions_step_over', nor does it specify prerequisites beyond the breakpoint requirement, leaving some ambiguity.

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/Kaina3/Debug-MCP'

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