MES Document MCP

MES Document MCP

Enables AI agents to safely ingest, inspect, edit, and export manufacturing documents (Excel, PDF, Word, Markdown) with controlled patch workflows and MES entity extraction.

Category
访问服务器

README

MES Document MCP

CI

AI agents need a safe way to work with real manufacturing documents. This project provides a production-oriented MCP server and CLI for Excel, PDF, Word, and Markdown files used in MES workflows.

It does not try to make an LLM directly edit office files. It turns documents into a structured DocumentIR, keeps source provenance, requires approved PatchIR edits, validates output artifacts, and exports back to md, docx, pdf, or xlsx.

What This Is

This repository contains:

  • An MCP server: uv run python -m mes_doc_mcp.server
  • A CLI: uv run mes-doc-mcp ...
  • A Python package: mes_doc_mcp
  • Parsers for Excel, PDF, Word, Markdown, and CSV
  • MES extraction and validation helpers
  • Secure patch/edit/export workflow
  • Tests and CI gates for public GitHub use

Typical users:

  • MES engineers handling production Excel files
  • Manufacturing data teams cleaning mixed office documents
  • AI agent builders who need document tools with citations and guarded edits
  • Teams converting messy spreadsheets into reports and standard JSON

Why It Exists

MES teams often receive business-critical data in Excel, Word, PDF, and Markdown:

  • production daily reports
  • work orders
  • quality inspection sheets
  • defect reports
  • BOM and routing tables
  • LOT traceability documents

LLMs are useful here, but unsafe if they directly mutate files. This server gives the agent controlled tools instead.

source file
→ secure ingest
→ DocumentIR with source refs
→ search / inspect / MES extraction
→ PatchIR proposal
→ dry-run diff
→ human approval
→ apply
→ validate
→ export artifact

Quickstart

git clone https://github.com/sjMun09/MES-mcp.git
cd MES-mcp
uv sync --extra dev
uv run pytest -q

Create sample files:

uv run python scripts/create_examples.py

Try the CLI:

uv run mes-doc-mcp ingest examples/sample_production.xlsx
uv run mes-doc-mcp list
uv run mes-doc-mcp validate DOC_ID
uv run mes-doc-mcp mes DOC_ID
uv run mes-doc-mcp export DOC_ID md examples/out/production_report.md

Run the MCP server:

uv run python -m mes_doc_mcp.server

More detail:

MCP Client Config

Use this from the repository root:

{
  "mcpServers": {
    "mes-doc-mcp": {
      "command": "uv",
      "args": ["run", "python", "-m", "mes_doc_mcp.server"],
      "cwd": "/absolute/path/to/MES-mcp"
    }
  }
}

Then ask your AI client:

Ingest examples/sample_production.xlsx.
Inspect sheets, tables, formulas, merged cells, and source ranges.
Extract MES entities and validate quantity consistency.
Propose fixes as PatchIR only. Do not apply changes until I approve.

Supported Formats

Format Read Patch Export Notes
.xlsx sheets, ranges, tables, formulas, comments, hyperlinks, merged cells, hidden rows/cols, image/chart metadata table cells, Excel cells md/docx/pdf/xlsx formula overwrite is blocked unless explicitly allowed
.xlsm same as xlsx restricted md/docx/pdf/xlsx macros are detected and never executed
.csv rows, encoding fallback table cells md/docx/pdf/xlsx UTF-8, CP949, EUC-KR, Latin-1 fallback
.md front matter, headings, paragraphs, lists, fenced code, tables, image links blocks/table cells md/docx/pdf/xlsx best round-trip format
.docx headings, paragraphs, tables, headers/footers, run style metadata, image metadata blocks/table cells md/docx/pdf/xlsx complex Word XML is not fully round-tripped
.pdf pages, text layer, table candidates, image metadata IR-level edits then regenerate md/docx/pdf/xlsx scanned PDFs require OCR outside this project

Main Tools

Document:

  • document_ingest
  • document_outline
  • document_search
  • document_read_chunk
  • document_extract_tables
  • document_inspect_capabilities
  • document_propose_edit
  • document_dry_run_edit
  • document_apply_edit
  • document_diff
  • document_validate
  • document_export

Excel:

  • excel_inspect_workbook
  • excel_read_range
  • excel_write_range
  • excel_evaluate_formulas
  • excel_recalculate_workbook

MES:

  • mes_classify_document
  • mes_extract_entities
  • mes_validate_data
  • mes_generate_report
  • mes_export_json

Safety Model

Defaults are intentionally conservative:

  • Original files are copied into immutable-style storage before parsing.
  • Writes require revision_id and approval_id.
  • Patches are schema-checked and dry-run capable.
  • Formula cell overwrite is blocked unless allow_formula_overwrite=true.
  • Export will not overwrite files unless explicitly requested.
  • Export artifacts are opened and hashed before publishing.
  • Macro/OLE/ActiveX/PDF JavaScript/zip traversal/zip bomb risks are detected.
  • Blocked ingest attempts are written to audit logs.
  • Document text is treated as untrusted data, not agent instructions.

Production Gates

Run before publishing changes:

uv sync --extra dev
uv run pytest -q
uv run python -m compileall -q src tests
uv build

Current local status:

14 passed
compileall ok
uv build ok
server import ok

Project Layout

src/mes_doc_mcp/
  server.py        MCP tool/resource/prompt server
  cli.py           local CLI
  models.py        DocumentIR, Block, SourceRef, PatchResult
  parsers/         Excel, CSV, Markdown, Word, PDF parsers
  patches.py       PatchIR validation and application
  renderers.py     md/docx/pdf/xlsx exporters
  validation.py    structural validation gates
  security.py      file risk detection
  artifacts.py     export artifact validation
  mes.py           MES classification/extraction/validation
  office.py        optional LibreOffice recalculation helper
tests/             regression and production-gate tests
docs/              public usage docs
examples/          generated sample documents
scripts/           helper scripts

Honest Limits

  • This is not OCR. Image-only scanned PDFs need an OCR step before useful extraction.
  • PDF body editing is not true round-trip editing. Edit IR and regenerate PDF.
  • .xls and .xlsb need a conversion layer before full support.
  • Complex pivot tables and charts are detected/preserved as metadata, not faithfully regenerated.
  • Real production confidence improves with site-specific golden fixtures.

License

MIT. See LICENSE.

推荐服务器

Baidu Map

Baidu Map

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

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

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

官方
精选
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

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

官方
精选
本地
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

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

官方
精选
本地
TypeScript
VeyraX

VeyraX

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

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

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

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

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

官方
精选
TypeScript
Exa MCP Server

Exa MCP Server

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

官方
精选
mcp-server-qdrant

mcp-server-qdrant

这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。

官方
精选
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选