RX

ruriazz/xlsx-tools-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

4 stars 0 forks 质量 79 趋势 19MIT

一个MCP服务器,用于高精度读写Excel(.xlsx)文件,同时保持文件的现有结构、样式和公式。

概览

一个MCP服务器,用于高精度读写Excel(.xlsx)文件,同时保持文件的现有结构、样式和公式。 xlsx-tools-mcp 提供了 29 种模型上下文协议(MCP)工具,这些工具为 LLM 代理提供了对 Excel .xlsx文件的准确、结构保持不变的读写权限。它运行为标准的标准 MCP 服务器:你只需安装并注册到 MCP 客户端(如 Claude Code、OpenCode 等),客户端代理可以列出工作表、读取单元格范围、搜索值、汇总数据、编写单元格/公式、管理表格/行/列、应用样式,并强制公式重新计算。 它基于这样一个原则:编辑现有的练习册应当销毁它未涉及的内容。 - — 写入加载现有工作簿并保存回去,保留样式、合并的单元格、注释以及编辑未涉及的任何方面。- — OpenPyXL 编写公式字符串,但从不评估它们。

概述(AI 翻译)

一个MCP服务器,用于高精度读写Excel(.xlsx)文件,同时保持文件的现有结构、样式和公式。


概述

xlsx-tools-mcp 提供了 29 个模型上下文协议(MCP)工具,这些工具为 LLM 代理提供准确、结构保持的读写权限,访问 Excel .xlsx 文件。它运行为标准的标准 MCP 服务器:你安装并注册给 MCP 客户端(Claude Code、OpenCode 等),客户端代理可以列出表格、读取单元格范围、搜索值、聚合数据、写单元格/公式、管理表格/行/列、应用样式,并强制公式重新计算。

它基于这样一个原则:编辑现有工作簿不应**破坏它未涉及的内容。

特色

  • 通过openpyxl保持结构的写入 — 写入加载现有工作簿并保存回去,保留样式、合并的单元格、注释以及编辑未涉及的部分。
  • 通过LibreOffice重新计算的永不陈旧公式结果 — openpyxl写入公式字符串,但从不评估它们。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

xlsx-tools-mcp

An MCP server for reading and writing Excel (.xlsx) files with high accuracy, while preserving the file’s existing structure, styles, and formulas.


Overview

xlsx-tools-mcp exposes 29 Model Context Protocol (MCP) tools that give an LLM agent accurate, structure-preserving read and write access to Excel .xlsx files. It runs as a standard stdio MCP server: you install it and register it with an MCP client (Claude Code, OpenCode, etc.), and the client’s agent can list sheets, read cell ranges, search values, aggregate data, write cells/formulas, manage sheets/rows/columns, apply styles, and force formula recalculation.

It is built around the principle that editing an existing workbook should not destroy what it doesn’t touch.

Features

  • Structure-preserving writes via openpyxl — writes load the existing workbook and save it back, preserving styles, merged cells, comments, and any aspect the edit doesn’t touch.
  • Never-stale formula results via LibreOffice recalculation — openpyxl writes formula strings but never evaluates them. After every value/formula write the server runs a headless LibreOffice pass to recompute real results, then returns errors_found — any Excel error values (#REF!, #DIV/0!, #N/A, …) produced by the recalculation.
  • Fast reads via python-calamine — a Rust-backed parser for accurate, fast type inference, with an automatic openpyxl fallback when you need formulas/styles/comments or when calamine can’t parse the file.
  • pandas-based grouping/aggregation & querying — aggregate_sheet and query_sheet perform operations without destroying source structure, equipped with AST expression validation to block code injection.
  • Native Excel objects — create formal Excel Tables (create_table) with autofilter and styles, and native charts (create_chart for bar, line, pie, scatter).
  • Sheet lifecycle & formatting — rename sheets (rename_sheet), duplicate sheets with styles intact (copy_sheet), clear ranges (clear_range), and auto-fit column widths (autofit_columns).
  • Cross-platform reliability (Windows, macOS, Linux) — case-insensitive path confinement, comma or semicolon ; environment delimiters, safe atomic file replacement with transient lock retry (WinError 32 / antivirus defense), and silent headless recalculation without window flicker.
在 GitHub 查看完整 README

安装

uvx xlsx-tools-mcp
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "xlsx-tools-mcp": { "command": "uvx", "args": ["xlsx-tools-mcp"] } } }