Skip to main content
Glama

create_workbook

Generate new Excel workbooks using a specified filepath. Enables efficient workbook creation and supports Excel file manipulation tasks.

Instructions

Create new Excel workbook.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler decorated with @mcp.tool(). Resolves the full file path using get_excel_path, imports and calls the workbook creation implementation, handles errors, and returns success or error message.
    @mcp.tool()
    def create_workbook(filepath: str) -> str:
        """Create new Excel workbook."""
        try:
            full_path = get_excel_path(filepath)
            from excel_mcp.workbook import create_workbook as create_workbook_impl
            create_workbook_impl(full_path)
            return f"Created workbook at {full_path}"
        except WorkbookError as e:
            return f"Error: {str(e)}"
        except Exception as e:
            logger.error(f"Error creating workbook: {e}")
            raise
  • Core implementation function that creates a new openpyxl Workbook instance, optionally renames the default sheet, ensures directory exists, saves the file, and returns a dictionary with message, active sheet, and workbook object.
    def create_workbook(filepath: str, sheet_name: str = "Sheet1") -> dict[str, Any]:
        """Create a new Excel workbook with optional custom sheet name"""
        try:
            wb = Workbook()
            # Rename default sheet
            if "Sheet" in wb.sheetnames:
                sheet = wb["Sheet"]
                sheet.title = sheet_name
            else:
                wb.create_sheet(sheet_name)
    
            path = Path(filepath)
            path.parent.mkdir(parents=True, exist_ok=True)
            wb.save(str(path))
            return {
                "message": f"Created workbook: {filepath}",
                "active_sheet": sheet_name,
                "workbook": wb
            }
        except Exception as e:
            logger.error(f"Failed to create workbook: {e}")
            raise WorkbookError(f"Failed to create workbook: {e!s}")
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Create new Excel workbook' implies a write/mutation operation but provides no information about permissions required, whether it overwrites existing files, what happens if the filepath already exists, or any rate limits. 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 maximally concise - a single sentence with zero wasted words. It's front-loaded with the essential information and doesn't include any unnecessary elaboration. This is an example of efficient communication where every word earns its place.

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 that there's an output schema (which handles return values) and only one straightforward parameter, the description is minimally adequate. However, for a mutation tool with no annotations and multiple similar sibling tools, it should provide more context about behavioral expectations and differentiation from alternatives to be truly complete.

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

Parameters4/5

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

With only one parameter (filepath) and 0% schema description coverage, the description doesn't need to provide extensive parameter semantics. The single parameter is self-explanatory for a file creation operation, though some guidance on filepath format expectations would be helpful. The baseline for 0 parameters would be 4, and with one straightforward parameter, this maintains that level.

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 ('Create') and resource ('new Excel workbook'), making the tool's purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'create_worksheet' or 'create_table', which would require more specific language about what distinguishes creating a workbook from creating other Excel components.

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?

The description provides no guidance on when to use this tool versus alternatives. With multiple sibling tools for creating Excel components (workbook, worksheet, table, chart, pivot table), there's no indication of when this specific creation operation is appropriate versus other creation tools or related tools like 'write_data_to_excel'.

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