Skip to main content
Glama

sessions_state

Retrieve the current state of a debug session to monitor execution status, breakpoints, and variable values during Python debugging.

Instructions

Get the current state of a debug session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYesThe debug session ID

Implementation Reference

  • Main execution handler for the 'sessions_state' MCP tool. Extracts sessionId from arguments, fetches state from SessionManager, serializes to JSON, and returns as TextContent or appropriate error responses.
    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), } }), ) ]
  • JSON schema defining the input parameters for the 'sessions_state' tool: requires a 'sessionId' string.
    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 logic in the generic call_tool handler that routes 'sessions_state' calls to the specific _handle_sessions_state method.
    elif name == "sessions_state": return await self._handle_sessions_state(arguments)
  • Async wrapper method in SessionManager that delegates to synchronous get_state, used by the tool handler.
    async def get_state_async(self, session_id: str) -> SessionStateResponse: """ Async wrapper for get_state. Runs the synchronous get_state in a thread pool to avoid blocking. """ return await asyncio.to_thread(self.get_state, session_id)
  • Core method in SessionManager that retrieves the DebugSession by ID and returns its state as SessionStateResponse via to_state_response().
    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()

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