Skip to main content
Glama

sessions_state

Retrieve the current state of a debug session to inspect variables, breakpoints, and execution status during Python debugging.

Instructions

Get the current state of a debug session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesThe debug session ID

Implementation Reference

  • The primary handler function for the 'sessions_state' MCP tool. It validates the sessionId argument, retrieves the session state asynchronously from SessionManager, serializes it to JSON, and returns it as TextContent. Handles errors like missing sessionId, session not found, and general exceptions.
    async def _handle_sessions_state(self, arguments: dict) -> list[TextContent]:
        """
        Handler for sessions_state tool.
        
        Gets the current state of a debug session.
        """
        try:
            session_id = arguments.get("sessionId")
            if not session_id:
                return [
                    TextContent(
                        type="text",
                        text=json.dumps({
                            "error": {
                                "type": "ValueError",
                                "message": "sessionId is required",
                            }
                        }),
                    )
                ]
    
            state = await self.session_manager.get_state_async(session_id)
            result = state.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 getting session state")
            return [
                TextContent(
                    type="text",
                    text=json.dumps({
                        "error": {
                            "type": type(e).__name__,
                            "message": str(e),
                        }
                    }),
                )
            ]
  • Input schema definition for the sessions_state tool, specifying that a 'sessionId' string is required.
    Tool(
        name="sessions_state",
        description="Get the current state of a debug session",
        inputSchema={
            "type": "object",
            "properties": {
                "sessionId": {
                    "type": "string",
                    "description": "The debug session ID",
                },
            },
            "required": ["sessionId"],
        },
    ),
  • Tool dispatch registration in the call_tool handler, routing 'sessions_state' calls to the specific handler method.
    elif name == "sessions_state":
        return await self._handle_sessions_state(arguments)
  • Core helper method in SessionManager that retrieves the DebugSession by ID and converts it to a SessionStateResponse using the session's to_state_response() method. This is called via the async wrapper from the tool handler.
    def get_state(self, session_id: str) -> SessionStateResponse:
        """
        Get current session state.
    
        Args:
            session_id: Session ID
    
        Returns:
            Current state response
        """
        session = self.get_session(session_id)
        return session.to_state_response()
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the tool 'gets' state, implying a read-only operation, but doesn't clarify if this requires specific permissions, what data is returned, or any side effects. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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, clear sentence that front-loads the core purpose without unnecessary details. It efficiently communicates the tool's function in minimal words, earning its place with zero waste.

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 low complexity (one parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose but lacks context on usage, behavioral traits, or output format. For a debug session tool, more detail on what 'state' includes would be helpful, though the simplicity keeps it minimally viable.

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%, with the single parameter 'sessionId' documented in the schema. The description doesn't add any meaning beyond the schema, such as explaining session ID format or where to obtain it. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 tool's purpose with a specific verb ('Get') and resource ('current state of a debug session'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'sessions_create' or 'sessions_end', which would require mentioning this is a read operation versus creation/termination 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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing session), exclusions, or comparisons to siblings like 'sessions_breakpoint' for debugging control. Without this context, users must infer usage from the tool name alone.

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