### Development Setup for Excel MCP Server (Bash) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Clones the Excel MCP Server repository, installs Node.js dependencies, and Python requirements for development. ```bash git clone https://github.com/guillehr2/Excel-MCP-Server-Master.git cd Excel-MCP-Server-Master npm install pip install -r requirements.txt ``` -------------------------------- ### Install Excel MCP Server Globally (Bash) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Installs the Excel MCP Server globally using npm for faster startup and verifies the installation. ```bash npm install -g @guillehr2/excel-mcp-server # Verify installation excel-mcp-server --version ``` -------------------------------- ### Configure Claude Desktop with Global Installation (JSON) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Configuration for Claude Desktop to use the Excel MCP Server when installed globally. ```json { "mcpServers": { "excel-master": { "command": "excel-mcp-server" } } } ``` -------------------------------- ### Install Dependencies with Virtual Environment Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md This bash command sequence sets up a Python virtual environment and installs project dependencies from a requirements.txt file. It's a standard practice for managing project dependencies. ```bash python -m venv venv # Windows: venv\Scripts\activate # Unix/macOS: source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Verify Excel MCP Server Version (Bash) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Tests if the Excel MCP Server is installed and accessible by checking its version using npx. ```bash npx @guillehr2/excel-mcp-server --version ``` -------------------------------- ### Set Up and Activate Python Virtual Environment Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Guides users through creating and activating a Python virtual environment to manage project dependencies, followed by installing requirements from a file. ```bash python -m venv venv # On Windows: venv\Scripts\activate # On Unix/macOS source venv/bin/activate pip install -r requirements.txt ``` -------------------------------- ### Configure Claude Desktop with Local Development (JSON) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Configuration for Claude Desktop to use a locally developed version of the Excel MCP Server. ```json { "mcpServers": { "excel-master": { "command": "node", "args": ["C:/path/to/Excel-MCP-Server-Master/index.js"] } } } ``` -------------------------------- ### Install and Run Excel MCP Server Globally Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Provides an alternative installation method by installing the Excel MCP Server globally using npm and then running it. This can help resolve issues related to local package execution. ```bash npm install -g @guillehr2/excel-mcp-server excel-mcp-server ``` -------------------------------- ### Create and Write to Excel File (Python) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Demonstrates creating a new Excel workbook, writing data to a sheet, and saving the file using MCP tools. ```python # Create a new Excel workbook create_workbook_tool( filename="my_first_excel.xlsx", overwrite=True ) # Add some data write_sheet_data_tool( file_path="my_first_excel.xlsx", sheet_name="Sheet", start_cell="A1", data=[ ["Product", "Sales", "Profit"], ["Product A", 10000, 2000], ["Product B", 15000, 3500], ["Product C", 8000, 1200] ] ) # Save the file save_workbook_tool("my_first_excel.xlsx") ``` -------------------------------- ### Development Setup Bash Commands Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/README.md This snippet outlines the bash commands required to set up the development environment for the Excel MCP Server. It includes cloning the repository, installing Node.js dependencies, installing Python dependencies, and running the server in development mode. ```bash git clone https://github.com/guillehr2/Excel-MCP-Server-Master.git cd Excel-MCP-Server-Master npm install pip install -r requirements.txt node index.js ``` -------------------------------- ### Configure Claude Desktop with NPX (JSON) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Configuration for Claude Desktop to use the Excel MCP Server via npx, specifying the package and using the latest version. ```json { "mcpServers": { "excel-master": { "command": "npx", "args": [ "-y", "@guillehr2/excel-mcp-server@latest" ] } } } ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md This bash command installs the necessary Python packages for the Excel MCP Server using pip. It includes libraries like fastmcp, openpyxl, pandas, numpy, matplotlib, xlsxwriter, xlrd, and xlwt. ```bash pip install fastmcp openpyxl pandas numpy matplotlib xlsxwriter xlrd xlwt ``` -------------------------------- ### Create Formatted Excel Table (Python) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Creates an Excel file with a formatted table, including data, table name, style, and cell formatting. ```python # Create a formatted table create_formatted_table_tool( file_path="my_first_excel.xlsx", sheet_name="Sheet", start_cell="A1", data=[ ["Product", "Sales", "Profit", "Margin %"], ["Product A", 10000, 2000, "=C2/B2"], ["Product B", 15000, 3500, "=C3/B3"], ["Product C", 8000, 1200, "=C4/B4"] ], table_name="SalesData", table_style="TableStyleMedium9", formats={ "B2:C4": "#,##0", # Number format "D2:D4": "0.0%", # Percentage format "A1:D1": { # Header styling "bold": True, "fill_color": "4472C4", "font_color": "FFFFFF" } } ) ``` -------------------------------- ### Configure Claude Desktop with Specific NPX Version (JSON) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Configuration for Claude Desktop to use a specific version of the Excel MCP Server via npx for stability. ```json { "mcpServers": { "excel-master": { "command": "npx", "args": [ "-y", "@guillehr2/excel-mcp-server@1.0.3" ] } } } ``` -------------------------------- ### Configure Excel MCP Server in Claude Desktop Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/QUICK_INSTALL.md This JSON configuration snippet is added to the Claude Desktop config file to enable the Excel MCP Server. It specifies the command to run the server using npx and the latest version of the package. ```json { "mcpServers": { "excel-master": { "command": "npx", "args": [ "-y", "@guillehr2/excel-mcp-server@latest" ] } } } ``` -------------------------------- ### Install Excel MCP Server Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/README.md Provides instructions for installing the Excel MCP Server using npm or npx. The npx command is recommended for immediate use without global installation. ```bash npx @guillehr2/excel-mcp-server@latest ``` ```bash npm install -g @guillehr2/excel-mcp-server ``` -------------------------------- ### Excel MCP Server Configuration JSON Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Provides an example of the `claude_desktop_config.json` file, showing how to configure the MCP client to recognize the Excel MCP Server. It specifies the command and arguments to run the server. ```json { "mcpServers": { "excel-master": { "command": "npx", "args": ["-y", "@guillehr2/excel-mcp-server"] } } } ``` -------------------------------- ### Install Excel MCP Server from Source Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/PROJECT_STRUCTURE.md This sequence of commands clones the Excel MCP Server repository from GitHub, navigates into the project directory, and installs both Node.js and Python dependencies. ```Bash git clone https://github.com/guillehr2/Excel-MCP-Server-Master.git cd Excel-MCP-Server-Master npm install pip install -r requirements.txt ``` -------------------------------- ### Create Excel Dashboard with Visualizations Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md This Python function creates an Excel dashboard with tables and charts based on provided data and configuration. It requires libraries like pandas and openpyxl for data manipulation and Excel file creation. ```python create_dashboard_tool( file_path="dashboard.xlsx", data={ "KPIs": [ ["Metric", "Value", "Target", "Status"], ["Revenue", 125000, 120000, "Exceeded"], ["Customers", 1543, 1500, "Exceeded"], ["Satisfaction", 4.5, 4.0, "Exceeded"] ] }, dashboard_config={ "tables": [ { "sheet": "Dashboard", "name": "KPITable", "range": "KPIs!A1:D4", "style": "TableStyleDark1" } ], "charts": [ { "sheet": "Dashboard", "type": "column", "data_range": "KPIs!A1:B4", "title": "Performance Metrics", "position": "F2", "style": "colorful-3" } ] } ) ``` -------------------------------- ### Install Python Dependencies Manually Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Installs the required Python libraries for the Excel MCP Server manually. This includes libraries for data manipulation and Excel file handling. ```bash pip install fastmcp openpyxl pandas numpy matplotlib xlsxwriter xlrd xlwt ``` -------------------------------- ### Install and Run Pytest Tests Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/tests/README.md Installs pytest and pytest-cov dependencies and provides commands to run all tests, tests with coverage, or specific test files. ```bash # Install test dependencies pip install pytest pytest-cov # Run all tests pytest # Run with coverage pytest --cov=master_excel_mcp # Run specific test file pytest tests/test_basic_operations.py ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/CONTRIBUTING.md Installs all necessary development dependencies listed in the 'requirements-dev.txt' file using pip. ```bash pip install -r requirements-dev.txt ``` -------------------------------- ### Enable Debug Mode (Windows) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md This command enables debug logging for the Excel MCP Server on Windows by setting the EXCEL_MCP_DEBUG environment variable to true before running the server. ```bash # Windows set EXCEL_MCP_DEBUG=true npx @guillehr2/excel-mcp-server ``` -------------------------------- ### Create Financial Summary with Formulas Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md This example demonstrates creating a financial statement (Profit & Loss) in an Excel sheet, including calculations for totals and percentages using Excel formulas. It utilizes a tool to create a sheet with predefined data. ```python # Create financial report financial_data = [ ["Account", "Q1", "Q2", "Q3", "Q4", "Total"], ["Revenue", 100000, 120000, 115000, 140000, "=SUM(B2:E2)"], ["Cost of Goods", 60000, 72000, 69000, 84000, "=SUM(B3:E3)"], ["Gross Profit", "=B2-B3", "=C2-C3", "=D2-D3", "=E2-E3", "=SUM(B4:E4)"], ["Operating Expenses", 20000, 22000, 21000, 25000, "=SUM(B5:E5)"], ["Net Income", "=B4-B5", "=C4-C5", "=D4-D5", "=E4-E5", "=SUM(B6:E6)"] ] create_sheet_with_data_tool( file_path="financial_summary.xlsx", sheet_name="P&L Statement", data=financial_data, overwrite=True ) # Add percentage calculations update_cell_tool("financial_summary.xlsx", "P&L Statement", "G1", "% of Revenue") update_cell_tool("financial_summary.xlsx", "P&L Statement", "G3", "=F3/F2") update_cell_tool("financial_summary.xlsx", "P&L Statement", "G4", "=F4/F2") update_cell_tool("financial_summary.xlsx", "P&L Statement", "G5", "=F5/F2") update_cell_tool("financial_summary.xlsx", "P&L Statement", "G6", "=F6/F2") ``` -------------------------------- ### Install Excel MCP Server via NPX Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/PROJECT_STRUCTURE.md This snippet shows how to install and run the Excel MCP Server using NPX, a package runner tool for Node.js. It specifies the package name and arguments for execution. ```JSON { "mcpServers": { "excel-master": { "command": "npx", "args": ["-y", "@guillehr2/excel-mcp-server"] } } } ``` -------------------------------- ### Check Node.js Version Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Verifies the installed Node.js version to ensure compatibility with the Excel MCP Server. Requires Node.js 14.0 or higher. ```bash node --version ``` -------------------------------- ### Run Excel MCP Server in Debug Mode Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Starts the Excel MCP Server in debug mode to capture more detailed logs, aiding in the diagnosis of startup crashes. ```bash node index.js --debug ``` -------------------------------- ### Python Test Example for Workbook Creation Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/tests/README.md Demonstrates how to write unit tests in Python for the `create_workbook_tool` function, covering both successful creation and handling existing files. ```python import pytest from master_excel_mcp import create_workbook_tool def test_create_workbook_success(): """Test successful workbook creation.""" result = create_workbook_tool("test.xlsx", overwrite=True) assert result["success"] is True assert "file_path" in result def test_create_workbook_exists(): """Test workbook creation when file exists.""" # First create create_workbook_tool("test.xlsx", overwrite=True) # Try again without overwrite result = create_workbook_tool("test.xlsx", overwrite=False) assert result["success"] is False assert "exists" in result["error"] ``` -------------------------------- ### Clear NPX Cache and Use Specific Version Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md These bash commands clear the NPX cache on Windows and then execute a specific version of the Excel MCP Server package. This is useful for resolving issues with outdated cached versions. ```bash # Clear npx cache rmdir /s /q %LOCALAPPDATA%\npm-cache\_npx # Use specific version npx @guillehr2/excel-mcp-server@1.0.3 ``` -------------------------------- ### Install Excel MCP Server Globally via NPM Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/PROJECT_STRUCTURE.md This command installs the Excel MCP Server globally on your system using npm, making it accessible from any directory. ```Bash npm install -g @guillehr2/excel-mcp-server ``` -------------------------------- ### Enable Debug Mode (Unix/macOS) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md This command enables debug logging for the Excel MCP Server on Unix-like systems (Linux, macOS) by exporting the EXCEL_MCP_DEBUG environment variable to true before running the server. ```bash # Unix/macOS export EXCEL_MCP_DEBUG=true npx @guillehr2/excel-mcp-server ``` -------------------------------- ### Add Column Chart to Excel File (Python) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/quick-start.md Adds a column chart to an Excel file, specifying the data range, title, position, and style. ```python # Add a column chart add_chart_tool( file_path="my_first_excel.xlsx", sheet_name="Sheet", chart_type="column", data_range="A1:B4", title="Sales by Product", position="F2", style="colorful-1" ) ``` -------------------------------- ### Pytest Example for Workbook Creation Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/CONTRIBUTING.md Provides example tests using the pytest framework for a workbook creation tool. It includes tests for successful creation and for handling cases where the file already exists without overwrite permissions. Asserts are used to check the success status, error messages, and file existence. ```Python def test_create_workbook_success(): """Test successful workbook creation.""" result = create_workbook_tool("test.xlsx", overwrite=True) assert result["success"] is True assert os.path.exists("test.xlsx") def test_create_workbook_file_exists(): """Test workbook creation when file exists.""" # Create file first create_workbook_tool("test.xlsx", overwrite=True) # Try to create again without overwrite result = create_workbook_tool("test.xlsx", overwrite=False) assert result["success"] is False assert "already exists" in result["error"] ``` -------------------------------- ### Publish Excel MCP Server to PyPI Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/PROJECT_STRUCTURE.md This command sequence builds the Python package for the Excel MCP Server and uploads it to the Python Package Index (PyPI). It requires the 'build' and 'twine' packages to be installed. ```Bash python -m build twine upload dist/* ``` -------------------------------- ### Configure Excel MCP Server in MCP Client Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/README.md Demonstrates how to configure the Excel MCP Server within an MCP client's configuration. It shows examples for using npx with the latest or a specific version, global installation, and development mode. ```json { "mcpServers": { "excel-master": { "command": "npx", "args": [ "-y", "@guillehr2/excel-mcp-server@latest" ] } } } ``` ```json { "mcpServers": { "excel-master": { "command": "npx", "args": [ "-y", "@guillehr2/excel-mcp-server@1.0.7" ] } } } ``` ```json { "mcpServers": { "excel-master": { "command": "excel-mcp-server" } } } ``` ```json { "mcpServers": { "excel-master": { "command": "node", "args": ["path/to/Excel-MCP-Server-Master/index.js"] } } } ``` -------------------------------- ### Run Tests Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/CONTRIBUTING.md Executes the project's test suite using pytest to verify the setup and functionality. ```bash pytest tests/ ``` -------------------------------- ### Install Package in Development Mode Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/CONTRIBUTING.md Installs the project package in editable mode, allowing changes to be reflected immediately without reinstallation. ```bash pip install -e . ``` -------------------------------- ### Install Excel MCP Server via Pip Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/PROJECT_STRUCTURE.md This command installs the Excel MCP Server using pip, the package installer for Python. It assumes Python and pip are already set up. ```Bash pip install excel-mcp-server ``` -------------------------------- ### Apply Cell Styles and Formatting Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Demonstrates how to use `apply_style_tool` to format cell ranges with specific font sizes, bolding, colors, and borders. Also shows `apply_number_format_tool` for number formatting. ```python apply_style_tool( file_path="invoice.xlsx", sheet_name="Invoice", cell_range="A1", style_dict={ "font_size": 24, "bold": True, "font_color": "000080" } ) apply_style_tool( file_path="invoice.xlsx", sheet_name="Invoice", cell_range="A9:E9", style_dict={ "bold": True, "fill_color": "D3D3D3", "border_style": "thin" } ) apply_number_format_tool("invoice.xlsx", "Invoice", "D10:E16", "#,##0.00") ``` -------------------------------- ### Create Multi-Series Charts from Data Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Demonstrates using `create_chart_from_data_tool` to generate a column chart directly from provided data and `add_chart_tool` to add a pie chart for specific data slices, facilitating multi-faceted analysis. ```python # Product category performance category_data = [ ["Quarter", "Electronics", "Clothing", "Home & Garden", "Sports"], ["Q1", 125000, 89000, 76000, 54000], ["Q2", 132000, 92000, 81000, 58000], ["Q3", 128000, 105000, 79000, 62000], ["Q4", 145000, 118000, 88000, 71000] ] # Create and chart the data result = create_chart_from_data_tool( file_path="category_performance.xlsx", sheet_name="Categories", data=category_data, chart_type="column", title="Quarterly Performance by Category", position="G2", style="colorful-3", create_table=True, table_name="CategoryData", table_style="TableStyleLight15" ) # Add a pie chart for Q4 distribution add_chart_tool( file_path="category_performance.xlsx", sheet_name="Categories", chart_type="pie", data_range="B1:E1,B5:E5", title="Q4 Revenue Distribution", position="G20", style="colorful-1" ) ``` -------------------------------- ### Create and Analyze Sales Trends with Charts Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Utilizes `create_formatted_table_tool` to structure sales data and `add_chart_tool` to generate column and line charts for comparing sales performance and visualizing growth trends. ```python # Monthly sales data sales_trend_data = [ ["Month", "2023", "2024", "Growth"], ["Jan", 45000, 50000, "=(C2-B2)/B2"], ["Feb", 48000, 55000, "=(C3-B3)/B3"], ["Mar", 52000, 58000, "=(C4-B4)/B4"], ["Apr", 51000, 62000, "=(C5-B5)/B5"], ["May", 54000, 65000, "=(C6-B6)/B6"], ["Jun", 58000, 68000, "=(C7-B7)/B7"] ] # Create data and format it create_formatted_table_tool( file_path="sales_trend.xlsx", sheet_name="Sales Analysis", start_cell="A1", data=sales_trend_data, table_name="SalesTrend", table_style="TableStyleMedium2", formats={ "B2:C7": "#,##0", "D2:D7": "0.0%" } ) # Add comparison chart add_chart_tool( file_path="sales_trend.xlsx", sheet_name="Sales Analysis", chart_type="column", data_range="A1:C7", title="Sales Comparison 2023 vs 2024", position="F2", style="colorful-1" ) # Add growth trend line chart add_chart_tool( file_path="sales_trend.xlsx", sheet_name="Sales Analysis", chart_type="line", data_range="A1:A7,D1:D7", title="Growth Trend", position="F18", style="dark-blue" ) ``` -------------------------------- ### Run Excel MCP Server with Specific Version Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Troubleshoots issues with `npx @guillehr2/excel-mcp-server` by suggesting the use of a specific version. This command executes the server package directly using npx. ```bash npx @guillehr2/excel-mcp-server@1.0.3 ``` -------------------------------- ### Generate Professional Invoice Template Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md This example shows how to create a professional invoice template in Excel. It includes customer billing information, line items with quantity, price, and total calculations, as well as subtotal, tax, and grand total fields. The data is structured for easy population and calculation. ```python # Create an invoice invoice_data = [ ["INVOICE", "", "", "", ""], ["", "", "", "", ""], ["Invoice #:", "INV-2024-001", "", "Date:", "2024-01-15"], ["", "", "", "", ""], ["Bill To:", "", "", "", ""], ["Customer Name", "", "", "", ""], ["123 Main Street", "", "", "", ""], ["City, State 12345", "", "", "", ""], ["", "", "", "", ""], ["Item", "Description", "Qty", "Price", "Total"], ["001", "Professional Services", 10, 150.00, "=C10*D10"], ["002", "Consulting Hours", 5, 200.00, "=C11*D11"], ["003", "Support Package", 1, 500.00, "=C12*D12"], ["", "", "", "", ""], ["", "", "", "Subtotal:", "=SUM(E10:E12)"], ["", "", "", "Tax (10%):", "=E14*0.1"], ["", "", "", "Total:", "=E14+E15"] ] # Create invoice with formatting create_sheet_with_data_tool( file_path="invoice.xlsx", sheet_name="Invoice", data=invoice_data, overwrite=True ) # Apply professional formatting ws = open_workbook_tool("invoice.xlsx") ``` -------------------------------- ### Publish Excel MCP Server to NPM Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/PROJECT_STRUCTURE.md These scripts are used to publish the Excel MCP Server package to the NPM registry. One script is for Unix-like systems (Linux, macOS) and the other for Windows. ```Bash # Unix/Linux/macOS ./publish.sh ``` ```Bash # Windows publish.bat ``` -------------------------------- ### Structure Data for Executive Dashboard Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Illustrates structuring complex data for an executive dashboard, organizing KPIs, monthly performance, and product sales data into a dictionary format suitable for further processing or visualization. ```python # Create comprehensive executive dashboard dashboard_data = { "KPIs": [ ["Metric", "Current", "Previous", "Change"], ["Revenue", 2500000, 2300000, "=(B2-C2)/C2"], ["Customers", 15420, 14200, "=(B3-C3)/C3"], ["Avg Order Value", 162.3, 155.8, "=(B4-C4)/C4"], ["Customer Satisfaction", 4.6, 4.4, "=(B5-C5)/C5"] ], "Monthly": [ ["Month", "Revenue", "Orders", "New Customers"], ["Jan", 200000, 1230, 210], ["Feb", 215000, 1380, 245], ["Mar", 208000, 1290, 198], ["Apr", 225000, 1420, 267], ["May", 232000, 1465, 289], ["Jun", 240000, 1510, 301] ], "Products": [ ["Product", "Units Sold", "Revenue", "Margin %"], ["Premium Widget", 2500, 625000, 0.42], ["Standard Widget", 4200, 420000, 0.35], ["Basic Widget", 6800, 340000, 0.28], ["Accessories", 3200, 160000, 0.55] ] } ``` -------------------------------- ### Create Financial Analysis Workbook Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Generates a comprehensive financial analysis workbook in Excel. It includes creating income statements and balance sheets, adding tables and charts, and applying number formatting. ```python # Comprehensive financial analysis def create_financial_analysis(): # Financial data financial_data = { "Income Statement": [ ["Income Statement", "", "", "", ""], ["For Year Ended December 31, 2024", "", "", "", ""], ["", "", "", "", ""], ["", "Q1", "Q2", "Q3", "Q4", "Total"], ["Revenue", 250000, 275000, 265000, 310000, "=SUM(B5:E5)"], ["Cost of Revenue", 150000, 165000, 159000, 186000, "=SUM(B6:E6)"], ["Gross Profit", "=B5-B6", "=C5-C6", "=D5-D6", "=E5-E6", "=SUM(B7:E7)"], ["", "", "", "", ""], ["Operating Expenses:", "", "", "", ""], ["Sales & Marketing", 40000, 44000, 42000, 49000, "=SUM(B10:E10)"], ["R&D", 30000, 32000, 31000, 35000, "=SUM(B11:E11)"], ["G&A", 20000, 22000, 21000, 24000, "=SUM(B12:E12)"], ["Total OpEx", "=SUM(B10:B12)", "=SUM(C10:C12)", "=SUM(D10:D12)", "=SUM(E10:E12)", "=SUM(B13:E13)"], ["", "", "", "", ""], ["Operating Income", "=B7-B13", "=C7-C13", "=D7-D13", "=E7-E13", "=SUM(B15:E15)"], ["", "", "", "", ""], ["Margin Analysis:", "", "", "", ""], ["Gross Margin %", "=B7/B5", "=C7/C5", "=D7/D5", "=E7/E5", "=F7/F5"], ["Operating Margin %", "=B15/B5", "=C15/C5", "=D15/D5", "=E15/E5", "=F15/F5"] ], "Balance Sheet": [ ["Balance Sheet", "", ""], ["As of December 31, 2024", "", ""], ["", "", ""], ["Assets", "", "Amount"], ["Current Assets:", "", ""], ["Cash", "", 500000], ["Accounts Receivable", "", 250000], ["Inventory", "", 150000], ["Total Current Assets", "", "=SUM(C6:C8)"], ["", "", ""], ["Fixed Assets:", "", ""], ["Property & Equipment", "", 800000], ["Less: Depreciation", "", -200000], ["Net Fixed Assets", "", "=C12+C13"], ["", "", ""], ["Total Assets", "", "=C9+C14"], ["", "", ""], ["Liabilities & Equity", "", ""], ["Current Liabilities:", "", ""], ["Accounts Payable", "", 150000], ["Accrued Expenses", "", 50000], ["Total Current Liabilities", "", "=SUM(C20:C21)"], ["", "", ""], ["Long-term Debt", "", 300000], ["Total Liabilities", "", "=C22+C24"], ["", "", ""], ["Shareholders' Equity", "", "=C16-C25"], ["", "", ""], ["Total Liab. & Equity", "", "=C25+C27"] ] } # Create the workbook create_dashboard_tool( file_path="financial_analysis.xlsx", data=financial_data, dashboard_config={ "tables": [ { "sheet": "Analysis", "name": "IncomeTable", "range": "'Income Statement'!A4:F15", "style": "TableStyleMedium2" }, { "sheet": "Analysis", "name": "BalanceTable", "range": "'Balance Sheet'!A4:C29", "style": "TableStyleMedium2" } ], "charts": [ { "sheet": "Analysis", "type": "column", "data_range": "'Income Statement'!A4:E7", "title": "Quarterly Revenue vs Costs", "position": "A2", "style": "colorful-3" }, { "sheet": "Analysis", "type": "line", "data_range": "'Income Statement'!A17:E19", "title": "Margin Trends", "position": "H2", "style": "dark-blue" } ] } ) # Apply professional formatting apply_number_format_tool("financial_analysis.xlsx", "Income Statement", "B5:F15", "#,##0") apply_number_format_tool("financial_analysis.xlsx", "Income Statement", "B18:F19", "0.0%") apply_number_format_tool("financial_analysis.xlsx", "Balance Sheet", "C6:C29", "#,##0") return "Financial analysis workbook created!" # Create the financial analysis create_financial_analysis() ``` -------------------------------- ### Reinstall Python Dependencies Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Troubleshoots 'Module not found' errors by uninstalling and then reinstalling specific Python packages required by the server. ```bash pip uninstall fastmcp openpyxl pandas numpy -y pip install fastmcp openpyxl pandas numpy ``` -------------------------------- ### Create and Use a Copy of an Excel File Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Provides a Python solution to create a copy of an Excel file using the `shutil` module, allowing work on a duplicate to avoid locking issues with the original. ```python import shutil shutil.copy2("original.xlsx", "working_copy.xlsx") ``` -------------------------------- ### Run Excel MCP Server with Sudo (macOS/Linux) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Addresses permission issues on macOS and Linux by suggesting the use of `sudo` to run the server command. Caution is advised when using `sudo`. ```bash sudo npx @guillehr2/excel-mcp-server ``` -------------------------------- ### Run Excel MCP Server as Administrator (Windows) Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Addresses permission denied errors on Windows by suggesting to run the Command Prompt as an administrator before executing the server command. ```bash # Right-click Command Prompt -> Run as administrator npx @guillehr2/excel-mcp-server ``` -------------------------------- ### Create Regional Sales Dashboard Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Creates a regional sales dashboard in an Excel file, featuring a summary table and charts. The data is structured into 'Summary' and 'Details' sections. This function requires the `create_dashboard_tool` and the `regional_data` dictionary. ```python # Regional sales dashboard with multiple views regional_data = { "Summary": [ ["Region", "Q1", "Q2", "Q3", "Q4", "Total"], ["North", 250000, 275000, 265000, 290000, "=SUM(B2:E2)"], ["South", 180000, 195000, 205000, 215000, "=SUM(B3:E3)"], ["East", 220000, 240000, 235000, 260000, "=SUM(B4:E4)"], ["West", 195000, 210000, 225000, 245000, "=SUM(B5:E5)"], ["Total", "=SUM(B2:B5)", "=SUM(C2:C5)", "=SUM(D2:D5)", "=SUM(E2:E5)", "=SUM(F2:F5)"] ], "Details": [ ["Region", "Sales Rep", "Q1", "Q2", "Q3", "Q4"], ["North", "John Smith", 125000, 140000, 135000, 145000], ["North", "Jane Doe", 125000, 135000, 130000, 145000], ["South", "Bob Johnson", 90000, 95000, 100000, 105000], ["South", "Alice Brown", 90000, 100000, 105000, 110000], ["East", "Charlie Davis", 110000, 120000, 115000, 130000], ["East", "Diana Evans", 110000, 120000, 120000, 130000], ["West", "Frank Garcia", 95000, 105000, 110000, 120000], ["West", "Grace Harris", 100000, 105000, 115000, 125000] ] } # Create the regional dashboard create_dashboard_tool( file_path="regional_dashboard.xlsx", data=regional_data, dashboard_config={ "tables": [ { "sheet": "Dashboard", "name": "RegionalSummary", "range": "Summary!A1:F6", "style": "TableStyleDark1" } ], "charts": [ { "sheet": "Dashboard", "type": "column", "data_range": "Summary!A1:E5", "title": "Quarterly Performance by Region", "position": "A10", "style": "colorful-3" }, { "sheet": "Dashboard", "type": "line", "data_range": "Summary!A1:F5", "title": "Regional Trends", "position": "I10", "style": "dark-blue" } ] } ) ``` -------------------------------- ### Create Executive Dashboard Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Generates an executive dashboard in an Excel file. It defines data for tables and charts, including sheet names, ranges, styles, and chart types. Dependencies include the `create_dashboard_tool` function and the `dashboard_data` variable. ```python dashboard_result = create_dashboard_tool( file_path="executive_dashboard.xlsx", data=dashboard_data, dashboard_config={ "tables": [ { "sheet": "Dashboard", "name": "KPITable", "range": "KPIs!A1:D5", "style": "TableStyleDark2" }, { "sheet": "Dashboard", "name": "MonthlyTable", "range": "Monthly!A1:D7", "style": "TableStyleMedium9" } ], "charts": [ { "sheet": "Dashboard", "type": "line", "data_range": "Monthly!A1:B7", "title": "Revenue Trend", "position": "F2", "style": "dark-blue" }, { "sheet": "Dashboard", "type": "column", "data_range": "Products!A1:C5", "title": "Product Performance", "position": "F18", "style": "colorful-2" }, { "sheet": "Dashboard", "type": "pie", "data_range": "Products!A1:A5,C1:C5", "title": "Revenue by Product", "position": "M18", "style": "colorful-1" } ] } ) ``` -------------------------------- ### Check Python Version Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Verifies the installed Python version, which is necessary for the server's Python dependencies. Requires Python 3.8 or higher. ```bash python --version # or python3 --version ``` -------------------------------- ### Valid Excel Range Formats Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Provides examples of correct and incorrect cell range notations in Excel, useful for resolving 'RangeError: Invalid range'. ```python # Correct "A1:B10" "Sheet1!A1:B10" # Incorrect "A-B" "1:10" ``` -------------------------------- ### Clear npm Cache Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Resolves installation issues by clearing the npm cache. This command forces npm to clean its cache, which can sometimes resolve corrupted package data. ```bash npm cache clean --force ``` -------------------------------- ### Fix npm Global Permissions Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/troubleshooting.md Resolves permission issues related to npm global installations by configuring npm's prefix and updating the system's PATH environment variable. ```bash npm config set prefix ~/.npm-global export PATH=~/.npm-global/bin:$PATH ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/CONTRIBUTING.md Clones the Excel MCP Master Server repository and navigates into the project directory. This is the first step in setting up the development environment. ```bash git clone https://github.com/guillehr2/Excel-MCP-Server-Master.git cd Excel-MCP-Server-Master ``` -------------------------------- ### Create and Write to Excel Spreadsheet Source: https://github.com/guillehr2/excel-mcp-server-master/blob/main/docs/examples.md Demonstrates how to create a new Excel workbook, add a sheet, write data to cells, and save the workbook using Python. It includes creating headers and calculating totals using formulas. ```python # Create a new workbook create_workbook_tool("my_data.xlsx", overwrite=True) # Add a new sheet add_sheet_tool("my_data.xlsx", "Sales Data") # Write some data write_sheet_data_tool( file_path="my_data.xlsx", sheet_name="Sales Data", start_cell="A1", data=[ ["Date", "Product", "Quantity", "Price", "Total"], ["2024-01-01", "Widget A", 10, 25.99, "=C2*D2"], ["2024-01-02", "Widget B", 5, 35.50, "=C3*D3"], ["2024-01-03", "Widget A", 8, 25.99, "=C4*D4"] ] ) # Save the workbook save_workbook_tool("my_data.xlsx") ```