Excel MCP Server

repository·main·Indexed 21 days ago

https://github.com/negokaz/excel-mcp-server

A Model Context Protocol (MCP) server that enables AI models to read, write, and manipulate MS Excel data. It supports .xlsx, .xlsm, .xltx, and .xltm formats. Key tools include excel_read_sheet, excel_write_to_sheet, excel_create_table, and excel_format_range for styling cells. Windows users have access to additional features such as live editing and screen capture via excel_screen_capture.

Tokens
2.8K
Snippets
9
Records
23
Agent score
77%

What's inside excel-mcp-server

  1. Define Excel cell styles using ExcelStyle

    main

    The ExcelStyle structure is a JSON schema used to exchange Excel cell styling configurations via MCP. It is based on the Excelize library API and allows you to configure borders, fonts, fills, and number formats.

    Key Properties

    • border: An array of Border objects defining cell edges.
    • font: A Font object for text styling.
    • fill: A Fill object for background patterns and colors.
    • numFmt: A string representing a custom number format (e.g., #,##0.00).
    • decimalPlaces: An integer (0-30) specifying the number of decimal places.

    Implementation Rules

    • Colors: Must use hexadecimal format (#RRGGBB).
    • Required Fields: Only border.type is strictly required if a border object is provided; all other style properties are optional.
    {
      "font": {
        "bold": true,
        "size": 12,
        "color": "#000000"
      },
      "fill": {
        "type": "pattern",
        "pattern": "solid",
        "color": ["#FFFF00"]
      }
    }
  2. Install Excel MCP Server via NPM

    main

    To install the Excel MCP Server, add the following configuration to your MCP servers configuration file. The configuration differs depending on your operating system.

    Windows

    Use cmd /c npx to ensure compatibility:

    {
        "mcpServers": {
            "excel": {
                "command": "cmd",
                "args": ["/c", "npx", "--yes", "@negokaz/excel-mcp-server"],
                "env": {
                    "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000"
                }
            }
        }
    }

    Other Platforms (macOS/Linux)

    Use npx directly:

    {
        "mcpServers": {
            "excel": {
                "command": "npx",
                "args": ["--yes", "@negokaz/excel-mcp-server"],
                "env": {
                    "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000"
                }
            }
        }
    }
    {
        "mcpServers": {
            "excel": {
                "command": "cmd",
                "args": ["/c", "npx", "--yes", "@negokaz/excel-mcp-server"],
                "env": {
                    "EXCEL_MCP_PAGING_CELLS_LIMIT": "4000"
                }
            }
        }
    }
  3. Install Excel MCP Server via Smithery

    main

    To automatically install the Excel MCP Server for Claude Desktop using Smithery, run the following command:

    npx -y @smithery/cli install @negokaz/excel-mcp-server --client claude
    npx -y @smithery/cli install @negokaz/excel-mcp-server --client claude
  4. Write data to Excel with excel_write_to_sheet

    main

    Use excel_write_to_sheet to insert values into an Excel sheet.

    Arguments:

    • fileAbsolutePath (string): Absolute path to the Excel file.
    • sheetName (string): Name of the target sheet.
    • newSheet (boolean): If true, creates a new sheet; otherwise, writes to the existing sheet.
    • range (string): The target cell range (e.g., "A1:C10").
    • values (any): The values to write. To write a formula, the string must start with =.
  5. Create an Excel table with excel_create_table

    main

    Use excel_create_table to convert a range of cells into a formal Excel table.

    Arguments:

    • fileAbsolutePath (string): Absolute path to the Excel file.
    • sheetName (string): The sheet where the table will be created.
    • range (string): The cell range to be converted (e.g., "A1:C10").
    • tableName (string): The name of the new table.
  6. Copy an Excel sheet with excel_copy_sheet

    main

    Use excel_copy_sheet to duplicate an existing sheet within the same file.

    Arguments:

    • fileAbsolutePath (string): Absolute path to the Excel file.
    • srcSheetName (string): The name of the source sheet.
    • dstSheetName (string): The name of the destination sheet.
  7. Format Excel cells with excel_format_range

    main

    Use excel_format_range to apply styles (borders, fonts, fills, etc.) to a specific range of cells.

    Arguments:

    • fileAbsolutePath (string): Absolute path to the Excel file.
    • sheetName (string): Name of the sheet.
    • range (string): The range to format (e.g., "A1:C3").
    • styles (2D array): A 2D array of style objects matching the range size. Use null for cells that should not change style.

    Style Object Properties:

    • border: Array of border styles (type, color, style).
    • font: Font styling (bold, italic, underline, size, strike, color, vertAlign).
    • fill: Fill/background styling (type, pattern, color, shading).
    • numFmt: Custom number format string.
    • decimalPlaces: Number of decimal places (0-30).
  8. Capture Excel sheet screenshot with excel_screen_capture

    main

    [Windows only] Use excel_screen_capture to take a screenshot of a specific range within an Excel sheet.

    Arguments:

    • fileAbsolutePath (string): Absolute path to the Excel file.
    • sheetName (string): Name of the sheet.
    • range (string): Cell range to capture (e.g., "A1:C10"). Defaults to the first paging range.