get_session_info
Retrieve detailed information about a specific session in the CSV Editor MCP server, using the session ID for precise identification and data access.
Instructions
Get information about a specific session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes |
Implementation Reference
- Core handler function implementing the logic to retrieve and return detailed session information using the session manager and OperationResult wrapper.async def get_session_info( session_id: str, ctx: Context = None ) -> Dict[str, Any]: """Get information about a specific session. Args: session_id: Session ID ctx: FastMCP context Returns: Session information """ try: session_manager = get_session_manager() session = session_manager.get_session(session_id) if not session: return OperationResult( success=False, message="Session not found", error="Invalid session ID" ).model_dump() if ctx: await ctx.info(f"Retrieved info for session {session_id}") info = session.get_info() return OperationResult( success=True, message="Session info retrieved", session_id=session_id, data=info.model_dump() ).model_dump() except Exception as e: if ctx: await ctx.error(f"Failed to get session info: {str(e)}") return OperationResult( success=False, message="Failed to get session info", error=str(e) ).model_dump()
- src/csv_editor/server.py:160-166 (registration)FastMCP tool registration (@mcp.tool) with a thin wrapper function that delegates to the core implementation.@mcp.tool async def get_session_info( session_id: str, ctx: Context = None ) -> Dict[str, Any]: """Get information about a specific session.""" return await _get_session_info(session_id, ctx)
- Pydantic BaseModel defining the structure of session information returned by the tool in the 'data' field of OperationResult.class SessionInfo(BaseModel): """Information about a data session.""" session_id: str = Field(..., description="Unique session identifier") created_at: datetime = Field(..., description="Session creation time") last_accessed: datetime = Field(..., description="Last access time") row_count: int = Field(..., description="Number of rows in dataset") column_count: int = Field(..., description="Number of columns") columns: List[str] = Field(..., description="Column names") memory_usage_mb: float = Field(..., description="Memory usage in MB") operations_count: int = Field(0, description="Number of operations performed") file_path: Optional[str] = Field(None, description="Source file path")
- CSVSession.get_info() method that constructs and returns the SessionInfo object used by the tool handler.def get_info(self) -> SessionInfo: """Get session information.""" if self.df is None: raise ValueError("No data loaded in session") memory_usage = self.df.memory_usage(deep=True).sum() / (1024 * 1024) # Convert to MB return SessionInfo( session_id=self.session_id, created_at=self.created_at, last_accessed=self.last_accessed, row_count=len(self.df), column_count=len(self.df.columns), columns=self.df.columns.tolist(), memory_usage_mb=round(memory_usage, 2), operations_count=len(self.operations_history), file_path=self.file_path )