exstruct 0.3.7__tar.gz → 0.4.1__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.1}/PKG-INFO +37 -4
  2. {exstruct-0.3.7 → exstruct-0.4.1}/README.md +26 -3
  3. {exstruct-0.3.7 → exstruct-0.4.1}/pyproject.toml +15 -1
  4. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/backends/openpyxl_backend.py +10 -2
  5. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/cells.py +251 -10
  6. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/pipeline.py +59 -5
  7. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/shapes.py +1 -0
  8. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/engine.py +13 -0
  9. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/io/__init__.py +20 -1
  10. exstruct-0.4.1/src/exstruct/mcp/__init__.py +59 -0
  11. exstruct-0.4.1/src/exstruct/mcp/chunk_reader.py +413 -0
  12. exstruct-0.4.1/src/exstruct/mcp/extract_runner.py +309 -0
  13. exstruct-0.4.1/src/exstruct/mcp/io.py +61 -0
  14. exstruct-0.4.1/src/exstruct/mcp/server.py +312 -0
  15. exstruct-0.4.1/src/exstruct/mcp/tools.py +203 -0
  16. exstruct-0.4.1/src/exstruct/mcp/validate_input.py +76 -0
  17. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/models/maps.py +13 -13
  18. {exstruct-0.3.7 → exstruct-0.4.1}/LICENSE +0 -0
  19. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/__init__.py +0 -0
  20. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/cli/availability.py +0 -0
  21. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/cli/main.py +0 -0
  22. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/__init__.py +0 -0
  23. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/backends/__init__.py +0 -0
  24. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/backends/base.py +0 -0
  25. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/backends/com_backend.py +0 -0
  26. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/charts.py +0 -0
  27. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/integrate.py +0 -0
  28. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/logging_utils.py +0 -0
  29. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/modeling.py +0 -0
  30. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/ranges.py +0 -0
  31. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/core/workbook.py +0 -0
  32. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/errors.py +0 -0
  33. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/io/serialize.py +0 -0
  34. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/models/__init__.py +0 -0
  35. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/models/types.py +0 -0
  36. {exstruct-0.3.7 → exstruct-0.4.1}/src/exstruct/py.typed +0 -0
  37. {exstruct-0.3.7 → exstruct-0.4.1}/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.1
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,14 @@ 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: httpx>=0.27,<1.0 ; extra == 'all'
48
+ Requires-Dist: mcp>=1.6.0,<2.0.0 ; extra == 'mcp'
49
+ Requires-Dist: httpx>=0.27,<1.0 ; extra == 'mcp'
42
50
  Requires-Dist: pypdfium2>=5.1.0 ; extra == 'render'
43
51
  Requires-Dist: pillow>=12.0.0 ; extra == 'render'
44
52
  Requires-Dist: python-toon>=0.1.3 ; extra == 'toon'
@@ -48,6 +56,8 @@ Project-URL: Documentation, https://harumiweb.github.io/exstruct/
48
56
  Project-URL: Homepage, https://harumiweb.github.io/exstruct/
49
57
  Project-URL: Issues, https://github.com/harumiWeb/exstruct/issues
50
58
  Project-URL: Repository, https://github.com/harumiWeb/exstruct
59
+ Provides-Extra: all
60
+ Provides-Extra: mcp
51
61
  Provides-Extra: render
52
62
  Provides-Extra: toon
53
63
  Provides-Extra: yaml
@@ -66,8 +76,8 @@ ExStruct reads Excel workbooks and outputs structured data (cells, table candida
66
76
  ## Features
67
77
 
68
78
  - **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`.
79
+ - **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.
80
+ - **Formula map extraction**: emits `formulas_map` (formula string -> cell coordinates) via openpyxl/COM; enabled by default in `verbose` or via `include_formulas_map`.
71
81
  - **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
82
  - **Formats**: JSON (compact by default, `--pretty` available), YAML, TOON (optional dependencies).
73
83
  - **Table detection tuning**: adjust heuristics at runtime via API.
@@ -107,6 +117,30 @@ exstruct input.xlsx --pdf --image # PDF and PNGs (Excel required)
107
117
 
108
118
  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
119
 
120
+ ## MCP Server (stdio)
121
+
122
+ Install the MCP extras and run the stdio server:
123
+
124
+ ```bash
125
+ pip install exstruct[mcp]
126
+ exstruct-mcp --root C:\data --log-file C:\logs\exstruct-mcp.log --on-conflict rename
127
+ ```
128
+
129
+ Available tools:
130
+
131
+ - `exstruct.extract`
132
+ - `exstruct.read_json_chunk`
133
+ - `exstruct.validate_input`
134
+
135
+ Notes:
136
+
137
+ - Logs go to stderr (and optionally `--log-file`) to avoid contaminating stdio responses.
138
+ - On Windows with Excel, standard/verbose can use COM for richer extraction. On non-Windows, COM is unavailable and extraction uses openpyxl-based fallbacks.
139
+
140
+ MCP Setup Guide for Each AI Agent:
141
+
142
+ [MCP Server](https://harumiweb.github.io/exstruct/mcp/)
143
+
110
144
  ## Quick Start (Python)
111
145
 
112
146
  ```python
@@ -392,7 +426,6 @@ flowchart TD
392
426
  ```
393
427
  ````
394
428
 
395
-
396
429
  ## Example 2: General Application Form
397
430
 
398
431
  ### 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.1"
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,25 @@ 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
+ "httpx>=0.27,<1.0",
47
+ ]
40
48
  yaml = ["pyyaml>=6.0.3"]
41
49
  toon = ["python-toon>=0.1.3"]
42
50
  render = ["pypdfium2>=5.1.0", "Pillow>=12.0.0"]
51
+ mcp = [
52
+ "mcp>=1.6.0,<2.0.0",
53
+ "httpx>=0.27,<1.0",
54
+ ]
43
55
 
44
56
  [project.scripts]
45
57
  exstruct = "exstruct.cli.main:main"
58
+ exstruct-mcp = "exstruct.mcp.server:main"
46
59
 
47
60
  [project.urls]
48
61
  Homepage = "https://harumiweb.github.io/exstruct/"
@@ -120,6 +133,7 @@ markers = [
120
133
  ruff = "ruff check ."
121
134
  ruff-fix = "ruff check . --fix"
122
135
  mypy = "mypy src/exstruct --strict"
136
+ precommit-run = "pre-commit run -a"
123
137
  test = "pytest -vv --cov=exstruct --cov-report=term-missing --cov-report=xml" # uv sync --extra render --extra toon
124
138
  test-unit = "pytest -vv -m \"not com and not render\" --cov=exstruct --cov-report=term-missing --cov-report=xml"
125
139
  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