Skip to main content
Glama

create_pivot_table

Build a pivot table from specified columns in a source sheet, aggregate values with sum, mean, or custom functions, and optionally write the result to a new sheet or file.

Instructions

Build a pivot table from a source sheet and optionally write it to output_sheet/output_file.

Args: file_path: Workbook path. sheet_name: Source data sheet. index_cols: List of column names to use as index (rows). value_cols: Columns to aggregate. aggfunc: Aggregation function or dict (e.g. "sum", "mean" or {col: "sum"}). output_sheet: Optional destination sheet for pivot output. output_file: Optional file to write the pivot output. column_field: Optional field used for pivot columns. date_freq: Optional date grouping alias (e.g. 'ME', 'YE', 'W').

Returns: dict: Details about output including created sheet and saved pivot metadata.

Notes: - Writes to workbook when output_sheet/output_file is provided. Stores pivot definitions in _mcp_pivots for refresh.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aggfuncNosum
date_freqNo
file_pathYes
index_colsYes
sheet_nameYes
value_colsYes
output_fileNo
column_fieldNo
output_sheetNo
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses side effects: 'Writes to workbook when output_sheet/output_file is provided. Stores pivot definitions in _mcp_pivots for refresh.' It also states the return value contains output metadata. However, it does not mention potential overwriting of existing sheets or required permissions.

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 uses a clean Args/Returns/Notes structure. Each line addresses one parameter or behavioral note without redundancy. Despite covering nine parameters, it remains efficient and scannable.

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

Completeness4/5

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

The description covers all parameters, the return value, and the key side effect of storing pivot definitions. It is reasonably complete for a complex tool, but falls short of explaining the precedence when both output_sheet and output_file are provided, and the exact semantics of column_field.

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

Parameters5/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 for all 9 parameters. Every parameter is explained with added meaning: index_cols are 'List of column names to use as index (rows)', aggfunc gives examples ('sum', 'mean', {col: 'sum'}), date_freq provides format aliases ('ME', 'YE', 'W'), and output_sheet/output_file are contextualized as optional destinations. This is far more informative than the raw schema.

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 opens with a specific verb and resource: 'Build a pivot table from a source sheet and optionally write it to output_sheet/output_file.' This clearly states what the tool does and differentiates it from siblings like refresh_pivot_table (refresh vs create) and aggregate_data (pivot vs generic aggregation).

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

Usage Guidelines3/5

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

The description implies when to use the tool (when building pivot tables) but does not explicitly discuss alternatives or exclusions relative to other tools such as aggregate_data or value_counts. No 'when not to use' guidance is provided.

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/mbeps/excel-mcp'

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