Dynamic Excel MCP Server

Dynamic Excel MCP Server

Enables LLMs to automatically generate Excel files with custom structures, advanced formatting, multiple sheets, formulas, and charts from JSON schemas, with support for both local and remote deployment.

Category
访问服务器

README

Dynamic Excel MCP Server

Dynamic Excel file generation server using Model Context Protocol (MCP). This server allows LLMs to automatically create Excel files with any structure through dynamic JSON schemas.

🚀 Features

  • ✅ Generate Excel files from JSON schemas
  • Dual transport modes: Local (stdio) and Remote (HTTP/SSE)
  • Deploy anywhere: VPS, Cloud (AWS, GCP, Heroku), Docker
  • ✅ Multiple sheets support
  • ✅ Advanced formatting (styling, borders, colors)
  • ✅ Data validation and conditional formatting
  • ✅ Formulas and calculations
  • ✅ Charts support (limited)
  • ✅ Page setup and printing options
  • ✅ S3 and local file storage
  • ✅ Presigned URLs for secure downloads
  • ✅ Freeze panes, auto-filter
  • ✅ Merged cells and row grouping
  • ✅ API key authentication
  • ✅ CORS support for web clients

📦 Installation

npm install
npm run build

⚙️ Configuration

Create a .env file (copy from .env.example):

For Local (Stdio) Mode:

TRANSPORT_MODE=stdio  # Local MCP client mode
STORAGE_TYPE=local
DEV_STORAGE_PATH=./temp-files
LOG_LEVEL=info

For Remote (HTTP/SSE) Mode:

TRANSPORT_MODE=http  # Remote server mode
HTTP_PORT=3000
HTTP_HOST=0.0.0.0
ALLOWED_ORIGINS=*  # Or specific domains: https://app.example.com
API_KEY=your-secret-api-key  # Optional

STORAGE_TYPE=s3  # or 'local'
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=ap-southeast-1
S3_BUCKET=your-bucket
PRESIGNED_URL_EXPIRY=3600
LOG_LEVEL=info

🔧 Usage

🖥️ Local Mode (Stdio) - For Claude Desktop

Add to your Claude Desktop or MCP client configuration:

For macOS (~/Library/Application Support/Claude/claude_desktop_config.json):

{
  "mcpServers": {
    "excel-generator": {
      "command": "node",
      "args": ["/absolute/path/to/excel-mcp-server/build/index.js"],
      "env": {
        "STORAGE_TYPE": "local",
        "DEV_STORAGE_PATH": "./temp-files",
        "LOG_LEVEL": "info"
      }
    }
  }
}

For Windows (%APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "excel-generator": {
      "command": "node",
      "args": ["C:\\path\\to\\excel-mcp-server\\build\\index.js"],
      "env": {
        "STORAGE_TYPE": "local",
        "DEV_STORAGE_PATH": "./temp-files",
        "LOG_LEVEL": "info"
      }
    }
  }
}

🌐 Remote Mode (HTTP/SSE) - For Web Apps & Remote Access

Start the server:

# Using environment variable
TRANSPORT_MODE=http npm start

# Or using npm script
npm run start:http

# Or with .env file configured for http mode
npm start

Server endpoints:

http://localhost:3000/health   - Health check
http://localhost:3000/info     - Server information
http://localhost:3000/sse      - SSE endpoint for MCP clients

Example client usage:

See examples/client-example.ts for a complete TypeScript client example using the MCP SDK.

import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';

const transport = new SSEClientTransport(
  new URL('http://localhost:3000/sse'),
  {
    headers: { 'X-API-Key': 'your-api-key' } // If API_KEY is set
  }
);

const client = new Client({
  name: 'excel-client',
  version: '1.0.0',
}, { capabilities: {} });

await client.connect(transport);
const result = await client.callTool({
  name: 'generate_excel',
  arguments: excelSchema
});

Deployment options:

  • 🐳 Docker: See DEPLOYMENT.md for Dockerfile and docker-compose examples
  • ☁️ Cloud: Deploy to AWS, GCP, Heroku, etc.
  • 🖧 VPS: Use PM2, systemd, or other process managers
  • 🔒 Production: Enable API key auth, configure CORS, use HTTPS

📚 Full deployment guide: See DEPLOYMENT.md

Tool: generate_excel

The server provides one tool: generate_excel

Input Schema:

{
  "file_name": "report.xlsx",
  "sheets": [
    {
      "name": "Sheet1",
      "columns": [...],
      "data": [...],
      "formatting": {...}
    }
  ],
  "metadata": {...},
  "options": {...}
}

📚 JSON Schema Structure

Column Configuration

{
  "header": "Column Name",
  "key": "data_key",
  "width": 20,
  "type": "currency",
  "format": "#,##0₫",
  "style": {
    "font": {"bold": true, "size": 12},
    "alignment": {"horizontal": "center"},
    "fill": {
      "type": "pattern",
      "pattern": "solid",
      "fgColor": {"argb": "FFFF0000"}
    }
  }
}

Supported Column Types

  • text: Plain text
  • number: Numeric values
  • currency: Currency format
  • percentage: Percentage format
  • date: Date format
  • datetime: Date and time format
  • boolean: Boolean values
  • formula: Excel formulas

Formatting Options

{
  "freeze_panes": "A2",
  "auto_filter": true,
  "conditional_formatting": [
    {
      "range": "A2:A100",
      "type": "cellIs",
      "operator": "greaterThan",
      "formulae": [0],
      "style": {
        "fill": {
          "type": "pattern",
          "pattern": "solid",
          "fgColor": {"argb": "FF90EE90"}
        }
      }
    }
  ],
  "totals_row": {
    "column_key": "=SUM(A2:A100)"
  },
  "merged_cells": ["A1:D1"],
  "row_heights": {
    "1": 30,
    "2": 25
  }
}

📖 Examples

1. Simple Data Table

See: examples/01-simple-table.json

Creates a basic product table with formatting:

  • Freeze panes
  • Auto-filter
  • Currency formatting

2. Financial Report

See: examples/02-financial-report.json

Advanced report with:

  • Report layout with title
  • Conditional formatting
  • Percentage calculations
  • Formula totals

3. Employee Database

See: examples/03-employee-database.json

Employee management spreadsheet with:

  • Multiple column types
  • Date formatting
  • Currency display
  • Auto-filter

4. Multi-Sheet Report

See: examples/04-multi-sheet-report.json

Comprehensive report with:

  • Multiple sheets
  • Summary and detail views
  • Cross-sheet consistency

🔨 Development

# Run in development mode (with auto-reload)
npm run dev

# Build TypeScript
npm run build

# Start production server
npm start

# Run tests
npm test

# Lint code
npm run lint

🧪 Testing with MCP Inspector

Test the server using the MCP Inspector:

npx @modelcontextprotocol/inspector node build/index.js

🎯 Use Cases

  1. Data Export: Export database queries to formatted Excel files
  2. Financial Reports: Generate quarterly/annual financial statements
  3. Inventory Management: Create product catalogs and stock reports
  4. HR Management: Employee databases and payroll reports
  5. Sales Analytics: Sales reports with charts and conditional formatting
  6. Project Tracking: Project status reports with multiple sheets

🏗️ Architecture

src/
├── index.ts                 # MCP Server entry point
├── types/
│   └── schema.ts           # TypeScript types & Zod schemas
├── generators/
│   ├── base-generator.ts   # Abstract base class
│   ├── basic-generator.ts  # Simple tables
│   └── report-generator.ts # Reports with styling
├── formatters/
│   ├── cell-formatter.ts   # Cell formatting
│   ├── style-formatter.ts  # Styling utilities
│   └── formula-builder.ts  # Formula generation
├── storage/
│   ├── s3-storage.ts       # S3 upload handler
│   └── local-storage.ts    # Local file system
├── validators/
│   └── schema-validator.ts # JSON schema validation
└── utils/
    ├── logger.ts           # Logging utility
    └── error-handler.ts    # Error handling

🔐 Security Notes

  • For S3 storage, ensure proper IAM permissions
  • Use presigned URLs for temporary file access
  • Set appropriate expiry times for download links
  • Validate all user inputs through Zod schemas

📝 License

MIT

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📧 Support

For issues and questions, please open an issue on GitHub.

🎉 Acknowledgments

Built with:

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选