Excel MCP Server is a powerful tool that allows you to read, write, and analyze Excel files through a Model Context Protocol (MCP) server. It provides comprehensive Excel file manipulation capabilities with built-in caching and logging functionalities.
For Claude Desktop users, you can easily install the Excel MCP server using Smithery:
npx -y @smithery/cli install @zhiwei5576/excel-mcp-server --client claude
You can manually configure the Excel MCP server by adding the appropriate configuration to your MCP servers setup.
For Windows:
{
"mcpServers": {
"excel": {
"command": "cmd",
"args": ["/c", "npx", "--yes", "@zhiweixu/excel-mcp-server"],
"env": {
"LOG_PATH": "[set an accessible absolute path]",
"CACHE_MAX_AGE": "1",
"CACHE_CLEANUP_INTERVAL": "4",
"LOG_RETENTION_DAYS": "7",
"LOG_CLEANUP_INTERVAL": "24"
}
}
}
}
For other platforms:
{
"mcpServers": {
"excel": {
"command": "npx",
"args": ["--yes", "@zhiweixu/excel-mcp-server"],
"env": {
"LOG_PATH": "[set an accessible absolute path]",
"CACHE_MAX_AGE": "1",
"CACHE_CLEANUP_INTERVAL": "4",
"LOG_RETENTION_DAYS": "7",
"LOG_CLEANUP_INTERVAL": "24"
}
}
}
}
Note: The LOG_PATH
environment variable is optional. If not set, logs will be stored in the 'logs' folder under the application root directory. Other environment variables are also optional.
analyzeExcelStructure({
fileAbsolutePath: "/path/to/your/file.xlsx",
headerRows: 1
})
This will return the Excel file structure including sheet list and column headers in JSON format.
exportExcelStructure({
sourceFilePath: "/path/to/source.xlsx",
targetFilePath: "/path/to/template.xlsx",
headerRows: 1
})
This exports the structure (sheets and headers) to a new Excel template file.
readSheetNames({
fileAbsolutePath: "/path/to/your/file.xlsx"
})
This returns all sheet names from the Excel file.
readDataBySheetName({
fileAbsolutePath: "/path/to/your/file.xlsx",
sheetName: "Sheet1",
headerRow: 1,
dataStartRow: 2
})
This reads data from a specific sheet in the Excel file.
readSheetData({
fileAbsolutePath: "/path/to/your/file.xlsx",
headerRow: 1,
dataStartRow: 2
})
This reads data from all sheets in the Excel file.
writeDataBySheetName({
fileAbsolutePath: "/path/to/your/file.xlsx",
sheetName: "Sheet1",
data: [
{ column1: "value1", column2: "value2" },
{ column1: "value3", column2: "value4" }
]
})
This writes data to a specific sheet (overwrites if the sheet exists).
writeSheetData({
fileAbsolutePath: "/path/to/new/file.xlsx",
data: {
"Sheet1": [
{ column1: "value1", column2: "value2" }
],
"Sheet2": [
{ columnA: "valueA", columnB: "valueB" }
]
}
})
This creates a new Excel file with data in multiple sheets.
clearFileCache({
fileAbsolutePath: "/path/to/your/file.xlsx"
})
This clears cached data for the specified Excel file.
The Excel MCP server can be configured using the following environment variables:
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "excel" '{"command":"npx","args":["--yes","@zhiweixu/excel-mcp-server"],"env":{"LOG_PATH":"[set an accessible absolute path]","CACHE_MAX_AGE":"1","CACHE_CLEANUP_INTERVAL":"4","LOG_RETENTION_DAYS":"7","LOG_CLEANUP_INTERVAL":"24"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"excel": {
"command": "npx",
"args": [
"--yes",
"@zhiweixu/excel-mcp-server"
],
"env": {
"LOG_PATH": "[set an accessible absolute path]",
"CACHE_MAX_AGE": "1",
"CACHE_CLEANUP_INTERVAL": "4",
"LOG_RETENTION_DAYS": "7",
"LOG_CLEANUP_INTERVAL": "24"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"excel": {
"command": "npx",
"args": [
"--yes",
"@zhiweixu/excel-mcp-server"
],
"env": {
"LOG_PATH": "[set an accessible absolute path]",
"CACHE_MAX_AGE": "1",
"CACHE_CLEANUP_INTERVAL": "4",
"LOG_RETENTION_DAYS": "7",
"LOG_CLEANUP_INTERVAL": "24"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect