使用docker compose 服务来启动excel-mcp-server
docker-compose.yml文件
version: '3.8' services: excel-mcp: image: python:3.11-slim container_name: excel-mcp-server restart: unless-stopped volumes: # 将本地 Excel 文件夹映射到容器内 - ./excel_files:/app/excel_files environment: - EXCEL_FILES_PATH=/app/excel_files - FASTMCP_PORT=8007 ports: - "8007:8007" command: > sh -c "pip install uv && uvx excel-mcp-server streamable-http"命令行启动
docker-compose up -dthe attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
[+] up 9/9
✔ Image python:3.11-slim Pulled 289.7s
✔ Network mcp-server-pandas_default Created 0.0s
✔ Container excel-mcp-server Started 0.3s
测试成功
curl -N -H "Accept: text/event-stream" http://localhost:8007/mcpexcel-mcp-server · PyPI
如果想实现生成excel后,可以下载
docker-compose.yml 文件
version: '3.8' services: # Excel MCP 服务:负责生成和处理 Excel 文件 excel-mcp: image: python:3.11-slim container_name: excel-mcp-server restart: unless-stopped volumes: # 将宿主机的 ./excel_files 目录映射到容器内的 /app/excel_files - ./excel_files:/app/excel_files environment: - EXCEL_FILES_PATH=/app/excel_files - FASTMCP_PORT=8007 ports: - "8007:8007" command: > sh -c "pip install uv && uvx excel-mcp-server streamable-http" networks: - excel-network # Nginx 静态文件服务:提供 Excel 文件的 HTTP 预览和下载 nginx-file-server: image: nginx:alpine container_name: excel-file-server restart: unless-stopped ports: - "8017:80" volumes: # 关键:共享同一个数据卷,Nginx 直接读取 excel-mcp 生成的文件 - ./excel_files:/usr/share/nginx/html/excels # 挂载自定义 Nginx 配置以优化 MIME 类型和目录浏览 - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: - excel-mcp networks: - excel-network networks: excel-network: driver: bridgenginx.conf
server { listen 80; server_name localhost; # 根路径指向 excels 目录 root /usr/share/nginx/html/excels; # 开启目录列表,方便查看有哪些文件可下载 autoindex on; autoindex_exact_size off; autoindex_localtime on; location / { # 默认尝试返回 index.html,如果没有则显示目录列表 try_files $uri $uri/ =404; # 设置正确的 MIME 类型,确保浏览器识别为 Excel 文件并触发下载或预览 types { application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; application/vnd.ms-excel xls; } # 添加缓存控制,可选 add_header Cache-Control "public, max-age=3600"; } # 安全限制:禁止访问隐藏文件 location ~ /\. { deny all; access_log off; log_not_found off; } }命令启动
docker-compose up -d