Skip to main content
Glama

create_table

Transform a specified data range into a native Excel table, enabling structured data management, formatting, and advanced analysis within Excel workbooks.

Instructions

Creates a native Excel table from a specified range of data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
data_rangeYes
filepathYes
sheet_nameYes
table_nameNo
table_styleNoTableStyleMedium9

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler and registration for 'create_table'. Resolves file path, calls the implementation, and handles errors.
    @mcp.tool()
    def create_table(
        filepath: str,
        sheet_name: str,
        data_range: str,
        table_name: Optional[str] = None,
        table_style: str = "TableStyleMedium9"
    ) -> str:
        """Creates a native Excel table from a specified range of data."""
        try:
            full_path = get_excel_path(filepath)
            result = create_table_impl(
                filepath=full_path,
                sheet_name=sheet_name,
                data_range=data_range,
                table_name=table_name,
                table_style=table_style
            )
            return result["message"]
        except DataError as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error creating table: {e}")
            raise
  • Core helper function that implements the Excel table creation using openpyxl.Table, including style application and validation.
    def create_excel_table(
        filepath: str,
        sheet_name: str,
        data_range: str,
        table_name: str | None = None,
        table_style: str = "TableStyleMedium9"
    ) -> dict:
        """Creates a native Excel table for the given data range.
        
        Args:
            filepath: Path to the Excel file.
            sheet_name: Name of the worksheet.
            data_range: The cell range for the table (e.g., "A1:D5").
            table_name: A unique name for the table. If not provided, a unique name is generated.
            table_style: The visual style to apply to the table.
            
        Returns:
            A dictionary with a success message and table details.
        """
        try:
            wb = load_workbook(filepath)
            if sheet_name not in wb.sheetnames:
                raise DataError(f"Sheet '{sheet_name}' not found.")
                
            ws = wb[sheet_name]
    
            # If no table name is provided, generate a unique one
            if not table_name:
                table_name = f"Table_{uuid.uuid4().hex[:8]}"
    
            # Check if table name already exists
            if table_name in ws.parent.defined_names:
                raise DataError(f"Table name '{table_name}' already exists.")
    
            # Create the table
            table = Table(displayName=table_name, ref=data_range)
            
            # Apply style
            style = TableStyleInfo(
                name=table_style, 
                showFirstColumn=False,
                showLastColumn=False, 
                showRowStripes=True, 
                showColumnStripes=False
            )
            table.tableStyleInfo = style
            
            ws.add_table(table)
            
            wb.save(filepath)
            
            return {
                "message": f"Successfully created table '{table_name}' in sheet '{sheet_name}'.",
                "table_name": table_name,
                "range": data_range
            }
    
        except Exception as e:
            logger.error(f"Failed to create table: {e}")
            raise DataError(str(e)) 
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action without behavioral details. It doesn't disclose whether this is a destructive operation (overwrites existing tables?), permission requirements, error conditions, or output format. For a tool with 5 parameters and no annotation coverage, this leaves significant gaps in understanding its behavior.

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 that front-loads the core purpose without unnecessary words. Every part earns its place by clearly stating the tool's function, making it easy to parse quickly.

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

Completeness2/5

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

Given 5 parameters with 0% schema coverage, no annotations, and sibling tools that might overlap (e.g., 'format_range'), the description is incomplete. It doesn't address key contextual aspects like input validation, error handling, or how it differs from similar tools. The presence of an output schema helps but doesn't compensate for these gaps.

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 but adds no parameter information beyond implying 'data_range' is used. It doesn't explain what 'native Excel table' entails, how parameters interact, or provide examples. With 5 parameters (3 required) and no schema descriptions, this is inadequate compensation.

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 action ('creates') and resource ('native Excel table from a specified range of data'), making the purpose immediately understandable. It distinguishes from siblings like 'create_workbook' or 'create_worksheet' by specifying table creation, though it doesn't explicitly contrast with alternatives like 'format_range' which might also manipulate tables.

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 Excel file or compare to 'format_range' for table styling. The description assumes context but offers no explicit usage rules or exclusions.

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

Related 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/haris-musa/excel-mcp-server'

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