close_session
Terminate and clean up a CSV editing session to free system resources and ensure proper data handling.
Instructions
Close and clean up a session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
Implementation Reference
- Core implementation of the close_session tool: removes the session from the session manager, handles errors, and returns a standardized result.async def close_session( session_id: str, ctx: Context = None ) -> Dict[str, Any]: """Close and clean up a session. Args: session_id: Session ID to close ctx: FastMCP context Returns: Operation result """ try: session_manager = get_session_manager() removed = await session_manager.remove_session(session_id) if not removed: return OperationResult( success=False, message="Session not found", error="Invalid session ID" ).model_dump() if ctx: await ctx.info(f"Closed session {session_id}") return OperationResult( success=True, message=f"Session {session_id} closed successfully", session_id=session_id ).model_dump() except Exception as e: if ctx: await ctx.error(f"Failed to close session: {str(e)}") return OperationResult( success=False, message="Failed to close session", error=str(e) ).model_dump()
- src/csv_editor/server.py:175-182 (registration)MCP tool registration for 'close_session' that delegates to the underlying implementation (_close_session).@mcp.tool async def close_session( session_id: str, ctx: Context = None ) -> Dict[str, Any]: """Close and clean up a session.""" return await _close_session(session_id, ctx)