list_sessions
Retrieve all active sessions in the CSV Editor MCP server to monitor ongoing data processing tasks and manage workflows effectively.
Instructions
List all active sessions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The primary handler function for the 'list_sessions' tool. It retrieves active sessions from the session manager and returns them in a standardized format with success/error handling.async def list_sessions(ctx: Context = None) -> Dict[str, Any]: """List all active sessions. Args: ctx: FastMCP context Returns: List of active sessions """ try: session_manager = get_session_manager() sessions = session_manager.list_sessions() if ctx: await ctx.info(f"Found {len(sessions)} active sessions") return { "success": True, "message": f"Found {len(sessions)} active sessions", "sessions": [s.model_dump() for s in sessions] } except Exception as e: if ctx: await ctx.error(f"Failed to list sessions: {str(e)}") return { "success": False, "message": "Failed to list sessions", "error": str(e) }
- src/csv_editor/server.py:169-173 (registration)MCP tool registration for 'list_sessions' using the @mcp.tool decorator. This wrapper delegates to the implementation in io_operations.py.@mcp.tool async def list_sessions(ctx: Context = None) -> Dict[str, Any]: """List all active sessions.""" return await _list_sessions(ctx)
- src/csv_editor/server.py:98-106 (registration)Import statement that brings in the 'list_sessions' implementation from io_operations.py, aliased for use in the server registration.from .tools.io_operations import ( load_csv as _load_csv, load_csv_from_url as _load_csv_from_url, load_csv_from_content as _load_csv_from_content, export_csv as _export_csv, get_session_info as _get_session_info, list_sessions as _list_sessions, close_session as _close_session )
- SessionManager helper method that performs the core logic of listing active sessions after cleanup, returning SessionInfo objects.def list_sessions(self) -> List[SessionInfo]: """List all active sessions.""" self._cleanup_expired() return [session.get_info() for session in self.sessions.values() if session.df is not None]