list_sessions
Display all active CSV editing sessions to manage ongoing data manipulation tasks within the CSV Editor MCP server.
Instructions
List all active sessions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- The core handler function implementing the list_sessions tool logic. It retrieves the session manager, lists active sessions, and returns formatted session information.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)Registration of the 'list_sessions' tool using the @mcp.tool decorator. This thin 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)
- Helper method in SessionManager class that performs the actual listing of 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]