Skip to main content
Glama
santoshray02

CSV Editor

by santoshray02

rename_columns

Change column names in CSV files to improve data clarity and consistency for analysis.

Instructions

Rename columns in the dataframe.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYes
mappingYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core handler function that performs the actual column renaming using pandas DataFrame.rename(), validates input columns, updates the session DataFrame, records the operation, and returns success status with updated columns.
    async def rename_columns(
        session_id: str, 
        mapping: Dict[str, str], 
        ctx: Context = None
    ) -> Dict[str, Any]:
        """
        Rename columns in the dataframe.
        
        Args:
            session_id: Session identifier
            mapping: Dict mapping old column names to new names
            ctx: FastMCP context
            
        Returns:
            Dict with success status and renamed columns
        """
        try:
            manager = get_session_manager()
            session = manager.get_session(session_id)
            
            if not session or session.df is None:
                return {"success": False, "error": "Invalid session or no data loaded"}
            
            df = session.df
            
            # Validate columns exist
            missing_cols = [col for col in mapping.keys() if col not in df.columns]
            if missing_cols:
                return {"success": False, "error": f"Columns not found: {missing_cols}"}
            
            session.df = df.rename(columns=mapping)
            session.record_operation(OperationType.RENAME, {
                "mapping": mapping
            })
            
            return {
                "success": True,
                "renamed": mapping,
                "columns": session.df.columns.tolist()
            }
            
        except Exception as e:
            logger.error(f"Error renaming columns: {str(e)}")
            return {"success": False, "error": str(e)}
  • MCP tool registration using @mcp.tool decorator. This wrapper function defines the tool interface and delegates execution to the core implementation in transformations.py.
    @mcp.tool
    async def rename_columns(
        session_id: str,
        mapping: Dict[str, str],
        ctx: Context = None
    ) -> Dict[str, Any]:
        """Rename columns in the dataframe."""
        return await _rename_columns(session_id, mapping, ctx)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the action ('rename columns') but lacks behavioral details such as whether this modifies data in-place, requires specific permissions, handles errors for non-existent columns, or what the output contains. This is inadequate for a mutation tool with zero annotation coverage.

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, efficient sentence with zero wasted words. It's front-loaded and directly states the tool's purpose without unnecessary elaboration, making it easy to parse quickly.

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 tool has an output schema (which covers return values), no annotations, and low schema coverage, the description is minimally complete but lacks crucial context. It identifies the action but misses details on parameters, behavioral traits, and usage guidelines, making it only adequate for basic understanding.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions 'columns in the dataframe' but doesn't explain the 'session_id' or 'mapping' parameters—what they represent, their formats, or examples. This leaves key semantics undocumented, failing to address the coverage gap.

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

Purpose4/5

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

The description clearly states the verb ('rename') and resource ('columns in the dataframe'), making the purpose immediately understandable. It doesn't explicitly distinguish from siblings like 'update_column' or 'remove_columns', but the action is specific enough to infer differentiation.

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 guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention prerequisites like needing an existing session or compare to similar tools like 'update_column' or 'change_column_type', leaving the agent to infer usage context.

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