exstruct 0.3.7__tar.gz → 0.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {exstruct-0.3.7 → exstruct-0.4.0}/PKG-INFO +35 -4
  2. {exstruct-0.3.7 → exstruct-0.4.0}/README.md +26 -3
  3. {exstruct-0.3.7 → exstruct-0.4.0}/pyproject.toml +11 -1
  4. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/backends/openpyxl_backend.py +10 -2
  5. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/cells.py +251 -10
  6. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/pipeline.py +59 -5
  7. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/shapes.py +1 -0
  8. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/engine.py +13 -0
  9. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/io/__init__.py +20 -1
  10. exstruct-0.4.0/src/exstruct/mcp/__init__.py +59 -0
  11. exstruct-0.4.0/src/exstruct/mcp/chunk_reader.py +413 -0
  12. exstruct-0.4.0/src/exstruct/mcp/extract_runner.py +309 -0
  13. exstruct-0.4.0/src/exstruct/mcp/io.py +61 -0
  14. exstruct-0.4.0/src/exstruct/mcp/server.py +312 -0
  15. exstruct-0.4.0/src/exstruct/mcp/tools.py +203 -0
  16. exstruct-0.4.0/src/exstruct/mcp/validate_input.py +76 -0
  17. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/models/maps.py +13 -13
  18. {exstruct-0.3.7 → exstruct-0.4.0}/LICENSE +0 -0
  19. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/__init__.py +0 -0
  20. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/cli/availability.py +0 -0
  21. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/cli/main.py +0 -0
  22. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/__init__.py +0 -0
  23. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/backends/__init__.py +0 -0
  24. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/backends/base.py +0 -0
  25. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/backends/com_backend.py +0 -0
  26. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/charts.py +0 -0
  27. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/integrate.py +0 -0
  28. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/logging_utils.py +0 -0
  29. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/modeling.py +0 -0
  30. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/ranges.py +0 -0
  31. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/core/workbook.py +0 -0
  32. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/errors.py +0 -0
  33. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/io/serialize.py +0 -0
  34. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/models/__init__.py +0 -0
  35. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/models/types.py +0 -0
  36. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/py.typed +0 -0
  37. {exstruct-0.3.7 → exstruct-0.4.0}/src/exstruct/render/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: exstruct
3
- Version: 0.3.7
3
+ Version: 0.4.0
4
4
  Summary: Excel to structured JSON (tables, shapes, charts) for LLM/RAG pipelines
5
5
  Keywords: excel,structure,data,exstruct
6
6
  Author: harumiWeb
@@ -39,6 +39,12 @@ Requires-Dist: pandas>=2.3.3
39
39
  Requires-Dist: pydantic>=2.12.5
40
40
  Requires-Dist: scipy>=1.16.3
41
41
  Requires-Dist: xlwings>=0.33.16
42
+ Requires-Dist: pyyaml>=6.0.3 ; extra == 'all'
43
+ Requires-Dist: python-toon>=0.1.3 ; extra == 'all'
44
+ Requires-Dist: pypdfium2>=5.1.0 ; extra == 'all'
45
+ Requires-Dist: pillow>=12.0.0 ; extra == 'all'
46
+ Requires-Dist: mcp>=1.6.0,<2.0.0 ; extra == 'all'
47
+ Requires-Dist: mcp>=1.6.0,<2.0.0 ; extra == 'mcp'
42
48
  Requires-Dist: pypdfium2>=5.1.0 ; extra == 'render'
43
49
  Requires-Dist: pillow>=12.0.0 ; extra == 'render'
44
50
  Requires-Dist: python-toon>=0.1.3 ; extra == 'toon'
@@ -48,6 +54,8 @@ Project-URL: Documentation, https://harumiweb.github.io/exstruct/
48
54
  Project-URL: Homepage, https://harumiweb.github.io/exstruct/
49
55
  Project-URL: Issues, https://github.com/harumiWeb/exstruct/issues
50
56
  Project-URL: Repository, https://github.com/harumiWeb/exstruct
57
+ Provides-Extra: all
58
+ Provides-Extra: mcp
51
59
  Provides-Extra: render
52
60
  Provides-Extra: toon
53
61
  Provides-Extra: yaml
@@ -66,8 +74,8 @@ ExStruct reads Excel workbooks and outputs structured data (cells, table candida
66
74
  ## Features
67
75
 
68
76
  - **Excel → Structured JSON**: cells, shapes, charts, smartart, table candidates, print areas/views, and auto page-break areas per sheet.
69
- - **Output modes**: `light` (cells + table candidates + print areas; no COM, shapes/charts empty), `standard` (texted shapes + arrows, charts, smartart, merged cell ranges, print areas), `verbose` (all shapes with width/height, charts with size, merged cell ranges, print areas). Verbose also emits cell hyperlinks and `colors_map`. Size output is flag-controlled.
70
- - **Formula map extraction**: emits `formulas_map` (formula string -> cell coordinates) via openpyxl/COM; enabled by default in `verbose` or via `include_formulas_map`.
77
+ - **Output modes**: `light` (cells + table candidates + print areas; no COM, shapes/charts empty), `standard` (texted shapes + arrows, charts, smartart, merged cell ranges, print areas), `verbose` (all shapes with width/height, charts with size, merged cell ranges, print areas). Verbose also emits cell hyperlinks and `colors_map`. Size output is flag-controlled.
78
+ - **Formula map extraction**: emits `formulas_map` (formula string -> cell coordinates) via openpyxl/COM; enabled by default in `verbose` or via `include_formulas_map`.
71
79
  - **Auto page-break export (COM only)**: capture Excel-computed auto page breaks and write per-area JSON/YAML/TOON when requested (CLI option appears only when COM is available).
72
80
  - **Formats**: JSON (compact by default, `--pretty` available), YAML, TOON (optional dependencies).
73
81
  - **Table detection tuning**: adjust heuristics at runtime via API.
@@ -107,6 +115,30 @@ exstruct input.xlsx --pdf --image # PDF and PNGs (Excel required)
107
115
 
108
116
  Auto page-break exports are available via API and CLI when Excel/COM is available; the CLI exposes `--auto-page-breaks-dir` only in COM-capable environments.
109
117
 
118
+ ## MCP Server (stdio)
119
+
120
+ Install the MCP extras and run the stdio server:
121
+
122
+ ```bash
123
+ pip install exstruct[mcp]
124
+ exstruct-mcp --root C:\data --log-file C:\logs\exstruct-mcp.log --on-conflict rename
125
+ ```
126
+
127
+ Available tools:
128
+
129
+ - `exstruct.extract`
130
+ - `exstruct.read_json_chunk`
131
+ - `exstruct.validate_input`
132
+
133
+ Notes:
134
+
135
+ - Logs go to stderr (and optionally `--log-file`) to avoid contaminating stdio responses.
136
+ - On Windows with Excel, standard/verbose can use COM for richer extraction. On non-Windows, COM is unavailable and extraction uses openpyxl-based fallbacks.
137
+
138
+ MCP Setup Guide for Each AI Agent:
139
+
140
+ [MCP Server](https://harumiweb.github.io/exstruct/mcp/)
141
+
110
142
  ## Quick Start (Python)
111
143
 
112
144
  ```python
@@ -392,7 +424,6 @@ flowchart TD
392
424
  ```
393
425
  ````
394
426
 
395
-
396
427
  ## Example 2: General Application Form
397
428
 
398
429
  ### Excel Sheet
@@ -11,8 +11,8 @@ ExStruct reads Excel workbooks and outputs structured data (cells, table candida
11
11
  ## Features
12
12
 
13
13
  - **Excel → Structured JSON**: cells, shapes, charts, smartart, table candidates, print areas/views, and auto page-break areas per sheet.
14
- - **Output modes**: `light` (cells + table candidates + print areas; no COM, shapes/charts empty), `standard` (texted shapes + arrows, charts, smartart, merged cell ranges, print areas), `verbose` (all shapes with width/height, charts with size, merged cell ranges, print areas). Verbose also emits cell hyperlinks and `colors_map`. Size output is flag-controlled.
15
- - **Formula map extraction**: emits `formulas_map` (formula string -> cell coordinates) via openpyxl/COM; enabled by default in `verbose` or via `include_formulas_map`.
14
+ - **Output modes**: `light` (cells + table candidates + print areas; no COM, shapes/charts empty), `standard` (texted shapes + arrows, charts, smartart, merged cell ranges, print areas), `verbose` (all shapes with width/height, charts with size, merged cell ranges, print areas). Verbose also emits cell hyperlinks and `colors_map`. Size output is flag-controlled.
15
+ - **Formula map extraction**: emits `formulas_map` (formula string -> cell coordinates) via openpyxl/COM; enabled by default in `verbose` or via `include_formulas_map`.
16
16
  - **Auto page-break export (COM only)**: capture Excel-computed auto page breaks and write per-area JSON/YAML/TOON when requested (CLI option appears only when COM is available).
17
17
  - **Formats**: JSON (compact by default, `--pretty` available), YAML, TOON (optional dependencies).
18
18
  - **Table detection tuning**: adjust heuristics at runtime via API.
@@ -52,6 +52,30 @@ exstruct input.xlsx --pdf --image # PDF and PNGs (Excel required)
52
52
 
53
53
  Auto page-break exports are available via API and CLI when Excel/COM is available; the CLI exposes `--auto-page-breaks-dir` only in COM-capable environments.
54
54
 
55
+ ## MCP Server (stdio)
56
+
57
+ Install the MCP extras and run the stdio server:
58
+
59
+ ```bash
60
+ pip install exstruct[mcp]
61
+ exstruct-mcp --root C:\data --log-file C:\logs\exstruct-mcp.log --on-conflict rename
62
+ ```
63
+
64
+ Available tools:
65
+
66
+ - `exstruct.extract`
67
+ - `exstruct.read_json_chunk`
68
+ - `exstruct.validate_input`
69
+
70
+ Notes:
71
+
72
+ - Logs go to stderr (and optionally `--log-file`) to avoid contaminating stdio responses.
73
+ - On Windows with Excel, standard/verbose can use COM for richer extraction. On non-Windows, COM is unavailable and extraction uses openpyxl-based fallbacks.
74
+
75
+ MCP Setup Guide for Each AI Agent:
76
+
77
+ [MCP Server](https://harumiweb.github.io/exstruct/mcp/)
78
+
55
79
  ## Quick Start (Python)
56
80
 
57
81
  ```python
@@ -337,7 +361,6 @@ flowchart TD
337
361
  ```
338
362
  ````
339
363
 
340
-
341
364
  ## Example 2: General Application Form
342
365
 
343
366
  ### Excel Sheet
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "exstruct"
3
- version = "0.3.7"
3
+ version = "0.4.0"
4
4
  description = "Excel to structured JSON (tables, shapes, charts) for LLM/RAG pipelines"
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -37,12 +37,21 @@ dev = [
37
37
  ]
38
38
 
39
39
  [project.optional-dependencies]
40
+ all = [
41
+ "pyyaml>=6.0.3",
42
+ "python-toon>=0.1.3",
43
+ "pypdfium2>=5.1.0",
44
+ "Pillow>=12.0.0",
45
+ "mcp>=1.6.0,<2.0.0",
46
+ ]
40
47
  yaml = ["pyyaml>=6.0.3"]
41
48
  toon = ["python-toon>=0.1.3"]
42
49
  render = ["pypdfium2>=5.1.0", "Pillow>=12.0.0"]
50
+ mcp = ["mcp>=1.6.0,<2.0.0"]
43
51
 
44
52
  [project.scripts]
45
53
  exstruct = "exstruct.cli.main:main"
54
+ exstruct-mcp = "exstruct.mcp.server:main"
46
55
 
47
56
  [project.urls]
48
57
  Homepage = "https://harumiweb.github.io/exstruct/"
@@ -120,6 +129,7 @@ markers = [
120
129
  ruff = "ruff check ."
121
130
  ruff-fix = "ruff check . --fix"
122
131
  mypy = "mypy src/exstruct --strict"
132
+ precommit-run = "pre-commit run -a"
123
133
  test = "pytest -vv --cov=exstruct --cov-report=term-missing --cov-report=xml" # uv sync --extra render --extra toon
124
134
  test-unit = "pytest -vv -m \"not com and not render\" --cov=exstruct --cov-report=term-missing --cov-report=xml"
125
135
  test-com = "pytest -vv -m \"com\" --cov=exstruct --cov-report=term-missing --cov-report=xml"
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  from dataclasses import dataclass
6
6
  import logging
7
7
  from pathlib import Path
8
+ from typing import Literal
8
9
 
9
10
  from ...models import PrintArea
10
11
  from ..cells import (
@@ -116,18 +117,25 @@ class OpenpyxlBackend:
116
117
  )
117
118
  return None
118
119
 
119
- def detect_tables(self, sheet_name: str) -> list[str]:
120
+ def detect_tables(
121
+ self,
122
+ sheet_name: str,
123
+ *,
124
+ mode: Literal["light", "standard", "verbose"] = "standard",
125
+ ) -> list[str]:
120
126
  """
121
127
  Detects table candidate ranges within the specified worksheet.
122
128
 
123
129
  Parameters:
124
130
  sheet_name (str): Name of the worksheet to analyze for table candidates.
131
+ mode (Literal["light", "standard", "verbose"]): Extraction mode, used to
132
+ adjust scan limits in openpyxl-based detection.
125
133
 
126
134
  Returns:
127
135
  list[str]: Detected table candidate ranges as A1-style range strings; empty list if none are found or detection fails.
128
136
  """
129
137
  try:
130
- return detect_tables_openpyxl(self.file_path, sheet_name)
138
+ return detect_tables_openpyxl(self.file_path, sheet_name, mode=mode)
131
139
  except Exception:
132
140
  return []
133
141