Excel Tools MCP

Excel Tools MCP

An MCP server for reading, writing, and analyzing Excel files using Python, pandas, and openpyxl. It enables tasks such as managing multiple worksheets, performing structural data analysis, and creating new files from JSON data.

Category
Visit Server

README

Excel Tools MCP

一个提供读取、写入和分析 Excel 文件工具的 MCP 服务器。基于 Python、pandasopenpyxl 构建。

安装使用

1.在 Glosc Copilot 中使用

2.配置使用

{
    "servers": {
        "Excel-Tools": {
            "type": "stdio",
            "command": "python",
            "args": [
              "main.py"
            ]
        }
    }
}

MCP 工具

  • get_excel_sheet_names(filepath):
    获取 Excel 文件中的工作表名称列表。

  • read_excel_sheet(filepath, sheet_name):
    读取指定工作表的数据。返回一个兼容 JSON 的记录列表(字典列表)。

  • read_all_excel_sheets(filepath):
    读取 Excel 文件中的所有工作表。返回一个字典,键为工作表名称,值为记录列表。

  • create_excel_file(filepath, data, sheet_name="Sheet1"):
    创建一个新的 Excel 文件。
    data 必须是表示字典列表的 JSON 字符串(例如:[{"col1": 1, "col2": "a"}, ...])。

  • add_excel_sheet(filepath, data, sheet_name):
    向现有的 Excel 文件添加一个新的工作表(如果文件存在则追加)。
    data 必须是表示字典列表的 JSON 字符串。

  • analyze_excel_structure(filepath, output_path=None):
    分析 Excel 文件的结构(行数、列名、数据类型、空值计数)。
    如果提供了 output_path,则将分析结果保存为 JSON 文件;否则,返回 JSON 字符串。

扩展:常用 Excel 编辑/格式工具

下面这些工具基于 openpyxl,用于修改 Excel 的样式与格式(列宽行高、合并、字体、背景、边框、格式等)。

  • set_excel_dimensions(filepath, sheet_names=None, column_widths=None, row_heights=None): 调整列宽/行高。

    • sheet_names: 传 null 表示对所有工作表生效;或传 ['Sheet1','Sheet2']
    • column_widths: 如 { "A": 20, "C": 12 }(列可用字母或数字字符串)。
    • row_heights: 如 { "1": 25, "2": 18 }(行号建议用字符串键)。
  • merge_excel_cells(filepath, ranges, sheet_names=None, unmerge=false): 合并/取消合并单元格。

    • ranges: 如 ["A1:C1", "D2:D5"]
    • unmerge=true 表示取消合并。
  • set_excel_font(filepath, targets, sheet_names=None, name=None, size=None, bold=None, italic=None, underline=None, color=None): 修改字体样式。

    • targets: 单元格或范围,如 ["A1", "B2:C3"]
    • color: 支持 "#RRGGBB" / "RRGGBB" / "FFRRGGBB"
  • set_excel_fill(filepath, targets, sheet_names=None, fill_color=None, pattern="solid", clear=false): 修改/清空单元格背景。

  • set_excel_number_format(filepath, targets, number_format, sheet_names=None): 设置单元格格式(数字/日期/文本等),例如:

    • "0.00""yyyy-mm-dd""@"(文本)
  • set_excel_border(filepath, targets, sheet_names=None, style="thin", color=None, sides=None, remove=false): 添加/移除边框。

    • sides: 默认四边,可传 ['left','right','top','bottom']
    • remove=true 表示移除对应边框
  • set_excel_alignment(filepath, targets, sheet_names=None, horizontal=None, vertical=None, wrap_text=None, text_rotation=None): 设置对齐与换行(常用:居中、自动换行)。

  • apply_excel_operations(filepath, operations): 批量执行多步操作(一次打开/保存,性能更好,适合“对多张表格做一组统一操作”)。

    • operations 是 JSON 字符串数组,每项包含 op 字段;支持: set_dimensions / merge_cells / set_font / set_fill / set_number_format / set_alignment / set_border / freeze_panes / set_auto_filter / set_sheet_protection / set_hidden / conditional_formatting

    示例(对所有 sheet:A 列宽 20,标题行加粗居中并加底色):

    [
      {"op":"set_dimensions","sheet_names":null,"column_widths":{"A":20}},
      {"op":"set_font","sheet_names":null,"targets":["1:1"],"bold":true},
      {"op":"set_alignment","sheet_names":null,"targets":["1:1"],"horizontal":"center","vertical":"center","wrap_text":true},
      {"op":"set_fill","sheet_names":null,"targets":["1:1"],"fill_color":"#F2F2F2"}
    ]
    

扩展:冻结/筛选/保护/隐藏/条件格式

  • freeze_excel_panes(filepath, cell=None, sheet_names=None): 冻结窗格。

    • cell: 例如 "B2" 表示冻结首行首列;传 null 表示取消冻结。
  • set_excel_auto_filter(filepath, ref=None, sheet_names=None, clear=false): 设置/清空自动筛选范围。

    • ref: 例如 "A1:D200"
    • clear=true 表示清空筛选范围
  • protect_excel_sheet(filepath, protect=true, sheet_names=None, password=None): 设置工作表保护(支持指定密码)。

    • protect=false 可关闭保护
  • set_excel_hidden(filepath, sheet_names=None, hide_rows=None, hide_cols=None, hidden=true): 隐藏/取消隐藏行列。

    • hide_rows: 例如 [2,3,4]
    • hide_cols: 例如 ["B","D"]
    • hidden=false 表示取消隐藏
  • set_excel_conditional_formatting(filepath, ranges, rule=None, sheet_names=None, clear=false): 添加/清空条件格式。

    • rule 为 JSON 字符串;支持:
      • color_scale: { "type":"color_scale", "start":"#63BE7B", "mid":"#FFEB84", "end":"#F8696B" }
      • cell_is: { "type":"cell_is", "operator":"greaterThan", "formula":["0"], "fill":"#FFF2CC" }
      • formula: { "type":"formula", "formula":["$A2>0"], "fill":"#C6EFCE" }
    • clear=true 会清空指定 sheet 的全部条件格式(快速清理用)

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured