Skip to main content
Glama
santoshray02

CSV Editor

by santoshray02

get_history

Retrieve the operation history for a CSV editing session, showing past actions and changes made.

Instructions

Get operation history for a session.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool registration for 'get_history' - a FastMCP @mcp.tool decorator that delegates to _get_operation_history.
    @mcp.tool
    async def get_history(
        session_id: str, limit: int | None = None, ctx: Context = None
    ) -> dict[str, Any]:
        """Get operation history for a session."""
        return await _get_operation_history(session_id, limit, ctx)
  • Handler function that resolves the session and calls session.get_history(limit) to retrieve operation history.
    async def get_operation_history(
        session_id: str, limit: int | None = None, ctx: Context = None
    ) -> dict[str, Any]:
        """
        Get operation history for a session.
    
        Args:
            session_id: Session identifier
            limit: Maximum number of operations to return
            ctx: FastMCP context
    
        Returns:
            Dict with history and statistics
        """
        try:
            manager = get_session_manager()
            session = manager.get_session(session_id)
    
            if not session:
                return OperationResult(
                    success=False,
                    message="Session not found",
                    error=f"No session with ID: {session_id}",
                ).model_dump()
    
            if ctx:
                await ctx.info(f"Getting operation history for session {session_id}")
    
            result = session.get_history(limit)
    
            if result["success"]:
                return OperationResult(
                    success=True,
                    message="History retrieved successfully",
                    session_id=session_id,
                    data=result,
                ).model_dump()
            else:
                return OperationResult(
                    success=False, message="Failed to get history", error=result.get("error")
                ).model_dump()
    
        except Exception as e:
            logger.error(f"Error getting history: {e!s}")
            if ctx:
                await ctx.error(f"Failed to get history: {e!s}")
            return OperationResult(
                success=False, message="Failed to get history", error=str(e)
            ).model_dump()
  • CSVSession.get_history - delegates to HistoryManager.get_history() and also returns statistics.
    def get_history(self, limit: int | None = None) -> dict[str, Any]:
        """Get operation history."""
        if not self.history_manager:
            # Return legacy history if new history is not enabled
            return {
                "success": True,
                "history": self.operations_history[-limit:] if limit else self.operations_history,
                "total": len(self.operations_history),
            }
    
        try:
            history = self.history_manager.get_history(limit)
            stats = self.history_manager.get_statistics()
    
            return {"success": True, "history": history, "statistics": stats}
        except Exception as e:
            logger.error(f"Error getting history: {e!s}")
            return {"success": False, "error": str(e)}
  • HistoryManager.get_history - the core implementation that builds a list of operation history dicts with index, is_current, and can_restore fields.
    def get_history(self, limit: int | None = None) -> list[dict[str, Any]]:
        """Get operation history."""
        history_list = []
    
        start = 0 if limit is None else max(0, len(self.history) - limit)
    
        for i, entry in enumerate(self.history[start:], start=start):
            history_dict = entry.to_dict()
            history_dict["index"] = i
            history_dict["is_current"] = i == self.current_index
            history_dict["can_restore"] = entry.data_snapshot is not None
            history_list.append(history_dict)
    
        return history_list
  • Helper that computes and returns statistics about the history (total operations, undo/redo state, operation type counts, etc.), called alongside get_history by CSVSession.get_history.
    def get_statistics(self) -> dict[str, Any]:
        """Get history statistics."""
        if not self.history:
            return {
                "total_operations": 0,
                "operation_types": {},
                "first_operation": None,
                "last_operation": None,
                "snapshots_count": 0,
            }
    
        # Count operation types
        operation_types = {}
        snapshots_count = 0
    
        for entry in self.history:
            operation_types[entry.operation_type] = operation_types.get(entry.operation_type, 0) + 1
            if entry.data_snapshot is not None:
                snapshots_count += 1
    
        return {
            "total_operations": len(self.history),
            "current_position": self.current_index + 1,
            "can_undo": self.can_undo(),
            "can_redo": self.can_redo(),
            "redo_stack_size": len(self.redo_stack),
            "operation_types": operation_types,
            "first_operation": self.history[0].timestamp.isoformat() if self.history else None,
            "last_operation": self.history[-1].timestamp.isoformat() if self.history else None,
            "snapshots_count": snapshots_count,
            "storage_type": self.storage_type.value,
            "max_history": self.max_history,
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose behavioral traits such as read-only nature, potential side effects, or data volume considerations. For a read operation, it should at least imply safety, but it remains silent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no superfluous words, achieving maximum conciseness for the given purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the existence of an output schema and only two simple parameters, the description could be minimally adequate. However, the lack of parameter details and behavioral context reduces completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, yet the description adds no clarity on parameters like 'session_id' format or 'limit' behavior (e.g., pagination, default value). Parameter names alone are insufficient.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Get operation history for a session.' clearly states the action (get) and the resource (operation history for a session). It distinguishes this tool from siblings like clear_history, export_history, and close_session.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage guidance is provided. The description does not specify when to use this tool, prerequisites, or alternatives among sibling tools like get_session_info or list_sessions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/santoshray02/csv-editor'

If you have feedback or need assistance with the MCP directory API, please join our Discord server