-write_data_to_excel is now context aware and checks for headers -fixed issue where headers were duplicated when appending data
7.3 KiB
Excel MCP Server Tools
This document provides detailed information about all available tools in the Excel MCP server.
Workbook Operations
create_workbook
Creates a new Excel workbook.
create_workbook(filepath: str) -> str
filepath: Path where to create workbook- Returns: Success message with created file path
create_worksheet
Creates a new worksheet in an existing workbook.
create_worksheet(filepath: str, sheet_name: str) -> str
filepath: Path to Excel filesheet_name: Name for the new worksheet- Returns: Success message
get_workbook_metadata
Get metadata about workbook including sheets and ranges.
get_workbook_metadata(filepath: str, include_ranges: bool = False) -> str
filepath: Path to Excel fileinclude_ranges: Whether to include range information- Returns: String representation of workbook metadata
Data Operations
write_data_to_excel
Write data to Excel worksheet.
write_data_to_excel(
filepath: str,
sheet_name: str,
data: List[Dict],
start_cell: str = "A1"
) -> str
filepath: Path to Excel filesheet_name: Target worksheet namedata: List of dictionaries containing data to writestart_cell: Starting cell (default: "A1")- Returns: Success message
read_data_from_excel
Read data from Excel worksheet.
read_data_from_excel(
filepath: str,
sheet_name: str,
start_cell: str = "A1",
end_cell: str = None,
preview_only: bool = False
) -> str
filepath: Path to Excel filesheet_name: Source worksheet namestart_cell: Starting cell (default: "A1")end_cell: Optional ending cellpreview_only: Whether to return only a preview- Returns: String representation of data
Formatting Operations
format_range
Apply formatting to a range of cells.
format_range(
filepath: str,
sheet_name: str,
start_cell: str,
end_cell: str = None,
bold: bool = False,
italic: bool = False,
underline: bool = False,
font_size: int = None,
font_color: str = None,
bg_color: str = None,
border_style: str = None,
border_color: str = None,
number_format: str = None,
alignment: str = None,
wrap_text: bool = False,
merge_cells: bool = False,
protection: Dict[str, Any] = None,
conditional_format: Dict[str, Any] = None
) -> str
filepath: Path to Excel filesheet_name: Target worksheet namestart_cell: Starting cell of rangeend_cell: Optional ending cell of range- Various formatting options (see parameters)
- Returns: Success message
merge_cells
Merge a range of cells.
merge_cells(filepath: str, sheet_name: str, start_cell: str, end_cell: str) -> str
filepath: Path to Excel filesheet_name: Target worksheet namestart_cell: Starting cell of rangeend_cell: Ending cell of range- Returns: Success message
unmerge_cells
Unmerge a previously merged range of cells.
unmerge_cells(filepath: str, sheet_name: str, start_cell: str, end_cell: str) -> str
filepath: Path to Excel filesheet_name: Target worksheet namestart_cell: Starting cell of rangeend_cell: Ending cell of range- Returns: Success message
Formula Operations
apply_formula
Apply Excel formula to cell.
apply_formula(filepath: str, sheet_name: str, cell: str, formula: str) -> str
filepath: Path to Excel filesheet_name: Target worksheet namecell: Target cell referenceformula: Excel formula to apply- Returns: Success message
validate_formula_syntax
Validate Excel formula syntax without applying it.
validate_formula_syntax(filepath: str, sheet_name: str, cell: str, formula: str) -> str
filepath: Path to Excel filesheet_name: Target worksheet namecell: Target cell referenceformula: Excel formula to validate- Returns: Validation result message
Chart Operations
create_chart
Create chart in worksheet.
create_chart(
filepath: str,
sheet_name: str,
data_range: str,
chart_type: str,
target_cell: str,
title: str = "",
x_axis: str = "",
y_axis: str = ""
) -> str
filepath: Path to Excel filesheet_name: Target worksheet namedata_range: Range containing chart datachart_type: Type of chart (line, bar, pie, scatter, area)target_cell: Cell where to place charttitle: Optional chart titlex_axis: Optional X-axis labely_axis: Optional Y-axis label- Returns: Success message
Pivot Table Operations
create_pivot_table
Create pivot table in worksheet.
create_pivot_table(
filepath: str,
sheet_name: str,
data_range: str,
target_cell: str,
rows: List[str],
values: List[str],
columns: List[str] = None,
agg_func: str = "mean"
) -> str
filepath: Path to Excel filesheet_name: Target worksheet namedata_range: Range containing source datatarget_cell: Cell where to place pivot tablerows: Fields for row labelsvalues: Fields for valuescolumns: Optional fields for column labelsagg_func: Aggregation function (sum, count, average, max, min)- Returns: Success message
Worksheet Operations
copy_worksheet
Copy worksheet within workbook.
copy_worksheet(filepath: str, source_sheet: str, target_sheet: str) -> str
filepath: Path to Excel filesource_sheet: Name of sheet to copytarget_sheet: Name for new sheet- Returns: Success message
delete_worksheet
Delete worksheet from workbook.
delete_worksheet(filepath: str, sheet_name: str) -> str
filepath: Path to Excel filesheet_name: Name of sheet to delete- Returns: Success message
rename_worksheet
Rename worksheet in workbook.
rename_worksheet(filepath: str, old_name: str, new_name: str) -> str
filepath: Path to Excel fileold_name: Current sheet namenew_name: New sheet name- Returns: Success message
Range Operations
copy_range
Copy a range of cells to another location.
copy_range(
filepath: str,
sheet_name: str,
source_start: str,
source_end: str,
target_start: str,
target_sheet: str = None
) -> str
filepath: Path to Excel filesheet_name: Source worksheet namesource_start: Starting cell of source rangesource_end: Ending cell of source rangetarget_start: Starting cell for pastetarget_sheet: Optional target worksheet name- Returns: Success message
delete_range
Delete a range of cells and shift remaining cells.
delete_range(
filepath: str,
sheet_name: str,
start_cell: str,
end_cell: str,
shift_direction: str = "up"
) -> str
filepath: Path to Excel filesheet_name: Target worksheet namestart_cell: Starting cell of rangeend_cell: Ending cell of rangeshift_direction: Direction to shift cells ("up" or "left")- Returns: Success message
validate_excel_range
Validate if a range exists and is properly formatted.
validate_excel_range(
filepath: str,
sheet_name: str,
start_cell: str,
end_cell: str = None
) -> str
filepath: Path to Excel filesheet_name: Target worksheet namestart_cell: Starting cell of rangeend_cell: Optional ending cell of range- Returns: Validation result message