yomitoku 0.8.1__tar.gz → 0.9.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 (183) hide show
  1. {yomitoku-0.8.1 → yomitoku-0.9.0}/PKG-INFO +3 -1
  2. yomitoku-0.9.0/docs/mcp.en.md +48 -0
  3. yomitoku-0.9.0/docs/mcp.ja.md +50 -0
  4. {yomitoku-0.8.1 → yomitoku-0.9.0}/mkdocs.yml +1 -0
  5. {yomitoku-0.8.1 → yomitoku-0.9.0}/pyproject.toml +6 -0
  6. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/cli/main.py +4 -3
  7. yomitoku-0.9.0/src/yomitoku/cli/mcp.py +165 -0
  8. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/export/export_csv.py +2 -2
  9. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/export/export_html.py +10 -5
  10. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/export/export_json.py +2 -2
  11. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/export/export_markdown.py +2 -2
  12. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/utils/misc.py +12 -0
  13. yomitoku-0.9.0/uv.lock +1815 -0
  14. yomitoku-0.8.1/uv.lock +0 -1610
  15. {yomitoku-0.8.1 → yomitoku-0.9.0}/.github/FUNDING.yml +0 -0
  16. {yomitoku-0.8.1 → yomitoku-0.9.0}/.github/release-drafter.yml +0 -0
  17. {yomitoku-0.8.1 → yomitoku-0.9.0}/.github/workflows/build-and-publish-docs.yaml +0 -0
  18. {yomitoku-0.8.1 → yomitoku-0.9.0}/.github/workflows/build-and-publish.yml +0 -0
  19. {yomitoku-0.8.1 → yomitoku-0.9.0}/.github/workflows/create-release.yml +0 -0
  20. {yomitoku-0.8.1 → yomitoku-0.9.0}/.github/workflows/lint-and-test.yml +0 -0
  21. {yomitoku-0.8.1 → yomitoku-0.9.0}/.gitignore +0 -0
  22. {yomitoku-0.8.1 → yomitoku-0.9.0}/.pre-commit-config.yaml +0 -0
  23. {yomitoku-0.8.1 → yomitoku-0.9.0}/.python-version +0 -0
  24. {yomitoku-0.8.1 → yomitoku-0.9.0}/README.md +0 -0
  25. {yomitoku-0.8.1 → yomitoku-0.9.0}/README_EN.md +0 -0
  26. {yomitoku-0.8.1 → yomitoku-0.9.0}/configs/yomitoku-layout-parser-rtdtrv2-open-beta.yaml +0 -0
  27. {yomitoku-0.8.1 → yomitoku-0.9.0}/configs/yomitoku-table-structure-recognizer-rtdtrv2-open-beta.yaml +0 -0
  28. {yomitoku-0.8.1 → yomitoku-0.9.0}/configs/yomitoku-text-detector-dbnet-open-beta.yaml +0 -0
  29. {yomitoku-0.8.1 → yomitoku-0.9.0}/configs/yomitoku-text-recognizer-parseq-open-beta.yaml +0 -0
  30. {yomitoku-0.8.1 → yomitoku-0.9.0}/configs/yomitoku-text-recognizer-parseq-small-open-beta.yaml +0 -0
  31. {yomitoku-0.8.1 → yomitoku-0.9.0}/demo/sample.pdf +0 -0
  32. {yomitoku-0.8.1 → yomitoku-0.9.0}/demo/setting_document_anaysis.py +0 -0
  33. {yomitoku-0.8.1 → yomitoku-0.9.0}/demo/simple_document_analysis.py +0 -0
  34. {yomitoku-0.8.1 → yomitoku-0.9.0}/demo/simple_layout.py +0 -0
  35. {yomitoku-0.8.1 → yomitoku-0.9.0}/demo/simple_ocr.py +0 -0
  36. {yomitoku-0.8.1 → yomitoku-0.9.0}/demo/text_detector.yaml +0 -0
  37. {yomitoku-0.8.1 → yomitoku-0.9.0}/dockerfile +0 -0
  38. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/assets/logo.svg +0 -0
  39. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/cli.en.md +0 -0
  40. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/cli.ja.md +0 -0
  41. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/configuration.en.md +0 -0
  42. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/configuration.ja.md +0 -0
  43. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/index.en.md +0 -0
  44. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/index.ja.md +0 -0
  45. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/installation.en.md +0 -0
  46. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/installation.ja.md +0 -0
  47. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/module.en.md +0 -0
  48. {yomitoku-0.8.1 → yomitoku-0.9.0}/docs/module.ja.md +0 -0
  49. {yomitoku-0.8.1 → yomitoku-0.9.0}/gallery.md +0 -0
  50. {yomitoku-0.8.1 → yomitoku-0.9.0}/pytest.ini +0 -0
  51. {yomitoku-0.8.1 → yomitoku-0.9.0}/scripts/register_hugging_face_hub.py +0 -0
  52. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/__init__.py +0 -0
  53. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/base.py +0 -0
  54. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/cli/__init__.py +0 -0
  55. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/__init__.py +0 -0
  56. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_layout_parser_rtdtrv2.py +0 -0
  57. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_layout_parser_rtdtrv2_v2.py +0 -0
  58. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_table_structure_recognizer_rtdtrv2.py +0 -0
  59. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_text_detector_dbnet.py +0 -0
  60. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_text_detector_dbnet_v2.py +0 -0
  61. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_text_recognizer_parseq.py +0 -0
  62. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_text_recognizer_parseq_small.py +0 -0
  63. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/configs/cfg_text_recognizer_parseq_v2.py +0 -0
  64. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/constants.py +0 -0
  65. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/data/__init__.py +0 -0
  66. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/data/dataset.py +0 -0
  67. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/data/functions.py +0 -0
  68. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/document_analyzer.py +0 -0
  69. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/export/__init__.py +0 -0
  70. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/layout_analyzer.py +0 -0
  71. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/layout_parser.py +0 -0
  72. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/__init__.py +0 -0
  73. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/dbnet_plus.py +0 -0
  74. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/layers/__init__.py +0 -0
  75. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/layers/activate.py +0 -0
  76. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/layers/dbnet_feature_attention.py +0 -0
  77. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/layers/parseq_transformer.py +0 -0
  78. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/layers/rtdetr_backbone.py +0 -0
  79. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/layers/rtdetr_hybrid_encoder.py +0 -0
  80. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/layers/rtdetrv2_decoder.py +0 -0
  81. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/parseq.py +0 -0
  82. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/models/rtdetr.py +0 -0
  83. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/ocr.py +0 -0
  84. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/onnx/.gitkeep +0 -0
  85. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/postprocessor/__init__.py +0 -0
  86. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/postprocessor/dbnet_postporcessor.py +0 -0
  87. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/postprocessor/parseq_tokenizer.py +0 -0
  88. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/postprocessor/rtdetr_postprocessor.py +0 -0
  89. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/reading_order.py +0 -0
  90. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/resource/MPLUS1p-Medium.ttf +0 -0
  91. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/resource/charset.txt +0 -0
  92. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/table_structure_recognizer.py +0 -0
  93. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/text_detector.py +0 -0
  94. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/text_recognizer.py +0 -0
  95. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/utils/__init__.py +0 -0
  96. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/utils/graph.py +0 -0
  97. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/utils/logger.py +0 -0
  98. {yomitoku-0.8.1 → yomitoku-0.9.0}/src/yomitoku/utils/visualizer.py +0 -0
  99. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/demo.jpg +0 -0
  100. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/gallery1.jpg +0 -0
  101. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/gallery2.jpg +0 -0
  102. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/gallery3.jpg +0 -0
  103. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/gallery4.jpg +0 -0
  104. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/gallery5.jpg +0 -0
  105. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/gallery6.jpg +0 -0
  106. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/in/gallery7.jpeg +0 -0
  107. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/logo/horizontal.png +0 -0
  108. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/demo_html.png +0 -0
  109. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_demo_p1_figure_0.png +0 -0
  110. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_0.png +0 -0
  111. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_1.png +0 -0
  112. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_10.png +0 -0
  113. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_2.png +0 -0
  114. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_3.png +0 -0
  115. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_4.png +0 -0
  116. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_5.png +0 -0
  117. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_6.png +0 -0
  118. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_7.png +0 -0
  119. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_8.png +0 -0
  120. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery1_p1_figure_9.png +0 -0
  121. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery3_p1_figure_0.png +0 -0
  122. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery3_p1_figure_1.png +0 -0
  123. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery5_p1_figure_0.png +0 -0
  124. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery5_p1_figure_1.png +0 -0
  125. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery6_p1_figure_0.png +0 -0
  126. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery6_p1_figure_1.png +0 -0
  127. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/figures/in_gallery7_p1_figure_0.png +0 -0
  128. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_demo_p1.html +0 -0
  129. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_demo_p1.md +0 -0
  130. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_demo_p1_layout.jpg +0 -0
  131. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_demo_p1_ocr.jpg +0 -0
  132. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery1_p1.html +0 -0
  133. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery1_p1.md +0 -0
  134. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery1_p1_layout.jpg +0 -0
  135. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery1_p1_ocr.jpg +0 -0
  136. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery2_p1.html +0 -0
  137. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery2_p1.md +0 -0
  138. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery2_p1_layout.jpg +0 -0
  139. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery2_p1_ocr.jpg +0 -0
  140. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery3_p1.html +0 -0
  141. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery3_p1.md +0 -0
  142. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery3_p1_layout.jpg +0 -0
  143. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery3_p1_ocr.jpg +0 -0
  144. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery4_p1.html +0 -0
  145. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery4_p1.md +0 -0
  146. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery4_p1_layout.jpg +0 -0
  147. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery4_p1_ocr.jpg +0 -0
  148. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery5_p1.html +0 -0
  149. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery5_p1.md +0 -0
  150. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery5_p1_layout.jpg +0 -0
  151. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery5_p1_ocr.jpg +0 -0
  152. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery6_p1.html +0 -0
  153. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery6_p1.md +0 -0
  154. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery6_p1_layout.jpg +0 -0
  155. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery6_p1_ocr.jpg +0 -0
  156. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery7_p1.html +0 -0
  157. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery7_p1.md +0 -0
  158. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery7_p1_layout.jpg +0 -0
  159. {yomitoku-0.8.1 → yomitoku-0.9.0}/static/out/in_gallery7_p1_ocr.jpg +0 -0
  160. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/invalid.jpg +0 -0
  161. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/invalid.pdf +0 -0
  162. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/rgba.png +0 -0
  163. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/sampldoc.tif +0 -0
  164. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/small.jpg +0 -0
  165. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/subdir/test.jpg +0 -0
  166. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/test.bmp +0 -0
  167. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/test.jpg +0 -0
  168. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/test.pdf +0 -0
  169. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/test.png +0 -0
  170. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/test.tiff +0 -0
  171. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/test.txt +0 -0
  172. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/data/test_gray.jpg +0 -0
  173. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/test_base.py +0 -0
  174. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/test_cli.py +0 -0
  175. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/test_data.py +0 -0
  176. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/test_document_analyzer.py +0 -0
  177. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/test_export.py +0 -0
  178. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/test_layout_analyzer.py +0 -0
  179. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/test_ocr.py +0 -0
  180. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/yaml/layout_parser.yaml +0 -0
  181. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/yaml/table_structure_recognizer.yaml +0 -0
  182. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/yaml/text_detector.yaml +0 -0
  183. {yomitoku-0.8.1 → yomitoku-0.9.0}/tests/yaml/text_recognizer.yaml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yomitoku
3
- Version: 0.8.1
3
+ Version: 0.9.0
4
4
  Summary: Yomitoku is an AI-powered document image analysis package designed specifically for the Japanese language.
5
5
  Author-email: Kotaro Kinoshita <kotaro.kinoshita@mlism.com>
6
6
  License: CC BY-NC-SA 4.0
@@ -19,6 +19,8 @@ Requires-Dist: shapely>=2.0.6
19
19
  Requires-Dist: timm>=1.0.11
20
20
  Requires-Dist: torch>=2.5.0
21
21
  Requires-Dist: torchvision>=0.20.0
22
+ Provides-Extra: mcp
23
+ Requires-Dist: mcp[cli]>=1.6.0; extra == 'mcp'
22
24
  Description-Content-Type: text/markdown
23
25
 
24
26
  日本語版 | [English](README_EN.md)
@@ -0,0 +1,48 @@
1
+ # MCP
2
+
3
+ This section explains how to use the Yomitoku MCP server in conjunction with Claude Desktop.
4
+
5
+ ## Installing Yomitoku
6
+
7
+ First, install Yomitoku by following the "Installation with uv" section in [Installation](installation.en.md).
8
+
9
+ However, to add `mcp` as a dependency during installation, include `mcp` in `--extra` as shown below.
10
+
11
+ ```bash
12
+ uv sync --extra mcp
13
+ ```
14
+
15
+ ## Setting up Claude Desktop
16
+
17
+ Next, add the following configuration to the `mcpServers` section of the Claude Desktop configuration file. (Refer to [here](https://modelcontextprotocol.io/quickstart/user) for how to open the configuration file)
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "yomitoku": {
23
+ "command": "uv",
24
+ "args": [
25
+ "--directory",
26
+ "(Absolute path of the directory where Yomitoku was cloned)",
27
+ "run",
28
+ "yomitoku_mcp"
29
+ ],
30
+ "env": {
31
+ "RESOURCE_DIR": "(Absolute path of the directory containing files for OCR)"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ For example, if you executed `git clone https://github.com/kotaro-kinoshita/yomitoku.git` in `/Users/your-username/workspace`, then `(Directory where Yomitoku was cloned)` would be `/Users/your-username/workspace/yomitoku`, and if you use `sample.pdf` in the `yomitoku/demo` directory, specify `(Directory containing files for OCR)` as `/Users/your-username/workspace/yomitoku/demo`.
39
+
40
+ ## Using Claude Desktop
41
+
42
+ * Please restart Claude Desktop to apply changes to the configuration file.
43
+
44
+ For example, if you use `yomitoku/demo/sample.pdf` as a sample, instruct as follows:
45
+
46
+ ```txt
47
+ Analyze sample.pdf using OCR and translate it into English.
48
+ ```
@@ -0,0 +1,50 @@
1
+ # MCP
2
+
3
+ ここではYomitokuのMCPサーバーをClaude Desktopに連携して利用する方法を説明します。
4
+
5
+ ## Yomitokuのインストール
6
+
7
+ まずは
8
+ [Installation](installation.ja.md)の「uvでのインストール」に従ってYomitokuをインストールしてください。
9
+
10
+ ただし、`mcp`を依存関係に追加するためにインストール時には下記のように`--extra`に`mcp`を加えます。
11
+
12
+ ```bash
13
+ uv sync --extra mcp
14
+ ```
15
+
16
+ ## Claude Desktopの設定
17
+
18
+ 次にClaude Desktopの設定ファイルの`mcpServers`に以下ように設定を追加します。(設定ファイルの開き方は[こちら](https://modelcontextprotocol.io/quickstart/user)を参照してください)
19
+
20
+ ```json
21
+ {
22
+ "mcpServers": {
23
+ "yomitoku": {
24
+ "command": "uv",
25
+ "args": [
26
+ "--directory",
27
+ "(YomitokuをCloneしたディレクトリの絶対パス)",
28
+ "run",
29
+ "yomitoku_mcp"
30
+ ],
31
+ "env": {
32
+ "RESOURCE_DIR": "(OCR対象のファイルがあるディレクトリの絶対パス)"
33
+ }
34
+ }
35
+ }
36
+ }
37
+ ```
38
+
39
+
40
+ 例えば、`/Users/your-username/workspace`で`git clone https://github.com/kotaro-kinoshita/yomitoku.git`を実行した場合は、`(YomitokuをCloneしたディレクトリ)`は`/Users/your-username/workspace/yomitoku`となり、`yomitoku/demo`ディレクトリの`sample.pdf`を用いる場合は`(OCR対象のファイルがあるディレクトリ)`を`/Users/your-username/workspace/yomitoku/demo`と指定します。
41
+
42
+ ## Claude Desktopでの利用
43
+
44
+ ※ 設定ファイルの変更を反映するにはClaude Desktopを再起動してください。
45
+
46
+ 例えば`yomitoku/demo/sample.pdf`をサンプルとして用いる場合、下記のように指示してください。
47
+
48
+ ```txt
49
+ sample.pdfをOCRで解析して要約してください。
50
+ ```
@@ -69,6 +69,7 @@ nav:
69
69
  - Installation: installation.md
70
70
  - CLI Usage: cli.md
71
71
  - Module Usage: module.md
72
+ - MCP: mcp.md
72
73
 
73
74
  repo_url: https://github.com/kotaro-kinoshita/yomitoku-dev
74
75
 
@@ -70,6 +70,12 @@ explicit = true
70
70
 
71
71
  [project.scripts]
72
72
  yomitoku = "yomitoku.cli.main:main"
73
+ yomitoku_mcp = "yomitoku.cli.mcp:run_mcp_server"
74
+
75
+ [project.optional-dependencies]
76
+ mcp = [
77
+ "mcp[cli]>=1.6.0",
78
+ ]
73
79
 
74
80
  [tool.tox]
75
81
  legacy_tox_ini = """
@@ -3,7 +3,6 @@ import os
3
3
  import time
4
4
  from pathlib import Path
5
5
 
6
- import cv2
7
6
  import torch
8
7
 
9
8
  from ..constants import SUPPORT_OUTPUT_FORMAT
@@ -14,6 +13,8 @@ from ..utils.logger import set_logger
14
13
  from ..export import save_csv, save_html, save_json, save_markdown
15
14
  from ..export import convert_json, convert_csv, convert_html, convert_markdown
16
15
 
16
+ from ..utils.misc import save_image
17
+
17
18
  logger = set_logger(__name__, "INFO")
18
19
 
19
20
 
@@ -94,7 +95,7 @@ def process_single_file(args, analyzer, path, format):
94
95
  args.outdir, f"{dirname}_{filename}_p{page+1}_ocr.jpg"
95
96
  )
96
97
 
97
- cv2.imwrite(out_path, ocr)
98
+ save_image(ocr, out_path)
98
99
  logger.info(f"Output file: {out_path}")
99
100
 
100
101
  if layout is not None:
@@ -102,7 +103,7 @@ def process_single_file(args, analyzer, path, format):
102
103
  args.outdir, f"{dirname}_{filename}_p{page+1}_layout.jpg"
103
104
  )
104
105
 
105
- cv2.imwrite(out_path, layout)
106
+ save_image(layout, out_path)
106
107
  logger.info(f"Output file: {out_path}")
107
108
 
108
109
  out_path = os.path.join(args.outdir, f"{dirname}_{filename}_p{page+1}.{format}")
@@ -0,0 +1,165 @@
1
+ import json
2
+ import io
3
+ import csv
4
+ import os
5
+ from pathlib import Path
6
+
7
+ from mcp.server.fastmcp import Context, FastMCP
8
+
9
+ from yomitoku import DocumentAnalyzer
10
+ from yomitoku.data.functions import load_image, load_pdf
11
+ from yomitoku.export import convert_json, convert_markdown, convert_csv, convert_html
12
+
13
+ try:
14
+ RESOURCE_DIR = os.environ["RESOURCE_DIR"]
15
+ except KeyError:
16
+ raise ValueError("Environment variable 'RESOURCE_DIR' is not set.")
17
+
18
+
19
+ analyzer = None
20
+
21
+
22
+ async def load_analyzer(ctx: Context) -> DocumentAnalyzer:
23
+ """
24
+ Load the DocumentAnalyzer instance if not already loaded.
25
+
26
+ Args:
27
+ ctx (Context): The context in which the analyzer is being loaded.
28
+
29
+ Returns:
30
+ DocumentAnalyzer: The loaded document analyzer instance.
31
+ """
32
+ global analyzer
33
+ if analyzer is None:
34
+ await ctx.info("Load document analyzer")
35
+ analyzer = DocumentAnalyzer(visualize=False, device="cuda")
36
+ return analyzer
37
+
38
+
39
+ mcp = FastMCP("yomitoku")
40
+
41
+
42
+ @mcp.tool()
43
+ async def process_ocr(ctx: Context, filename: str, output_format: str) -> str:
44
+ """
45
+ Perform OCR on the specified file in the resource direcory and convert
46
+ the results to the desired format.
47
+
48
+ Args:
49
+ ctx (Context): The context in which the OCR processing is executed.
50
+ filename (str): The name of the file to process in the resource directory.
51
+ output_format (str): The desired format for the output. The available options are:
52
+ - json: Outputs the text as structured data along with positional information.
53
+ - markdown: Outputs texts and tables in Markdown format.
54
+ - html: Outputs texts and tables in HTML format.
55
+ - csv: Outputs texts and tables in CSV format.
56
+
57
+ Returns:
58
+ str: The OCR results converted to the specified format.
59
+ """
60
+ analyzer = await load_analyzer(ctx)
61
+
62
+ await ctx.info("Start ocr processing")
63
+
64
+ file_path = os.path.join(RESOURCE_DIR, filename)
65
+ if Path(file_path).suffix[1:].lower() in ["pdf"]:
66
+ imgs = load_pdf(file_path)
67
+ else:
68
+ imgs = load_image(file_path)
69
+
70
+ results = []
71
+ for page, img in enumerate(imgs):
72
+ analyzer.img = img
73
+ result, _, _ = await analyzer.run(img)
74
+ results.append(result)
75
+ await ctx.report_progress(page + 1, len(imgs))
76
+
77
+ if output_format == "json":
78
+ return json.dumps(
79
+ [
80
+ convert_json(
81
+ result,
82
+ out_path=None,
83
+ ignore_line_break=True,
84
+ img=img,
85
+ export_figure=False,
86
+ figure_dir=None,
87
+ ).model_dump()
88
+ for img, result in zip(imgs, results)
89
+ ],
90
+ ensure_ascii=False,
91
+ sort_keys=True,
92
+ separators=(",", ": "),
93
+ )
94
+ elif output_format == "markdown":
95
+ return "\n".join(
96
+ [
97
+ convert_markdown(
98
+ result,
99
+ out_path=None,
100
+ ignore_line_break=True,
101
+ img=img,
102
+ export_figure=False,
103
+ )[0]
104
+ for img, result in zip(imgs, results)
105
+ ]
106
+ )
107
+ elif output_format == "html":
108
+ return "\n".join(
109
+ [
110
+ convert_html(
111
+ result,
112
+ out_path=None,
113
+ ignore_line_break=True,
114
+ img=img,
115
+ export_figure=False,
116
+ export_figure_letter="",
117
+ )[0]
118
+ for img, result in zip(imgs, results)
119
+ ]
120
+ )
121
+ elif output_format == "csv":
122
+ output = io.StringIO()
123
+ writer = csv.writer(output, quoting=csv.QUOTE_MINIMAL)
124
+ for img, result in zip(imgs, results):
125
+ elements = convert_csv(
126
+ result,
127
+ out_path=None,
128
+ ignore_line_break=True,
129
+ img=img,
130
+ export_figure=False,
131
+ )
132
+ for element in elements:
133
+ if element["type"] == "table":
134
+ writer.writerows(element["element"])
135
+ else:
136
+ writer.writerow([element["element"]])
137
+ writer.writerow([""])
138
+ return output.getvalue()
139
+ else:
140
+ raise ValueError(
141
+ f"Unsupported output format: {output_format}."
142
+ " Supported formats are json, markdown, html or csv."
143
+ )
144
+
145
+
146
+ @mcp.resource("file://list")
147
+ async def get_file_list() -> list[str]:
148
+ """
149
+ Retrieve a list of files in the resource directory.
150
+
151
+ Returns:
152
+ list[str]: A list of filenames in the resource directory.
153
+ """
154
+ return os.listdir(RESOURCE_DIR)
155
+
156
+
157
+ def run_mcp_server():
158
+ """
159
+ Run the MCP server.
160
+ """
161
+ mcp.run(transport="stdio")
162
+
163
+
164
+ if __name__ == "__main__":
165
+ run_mcp_server()
@@ -1,7 +1,7 @@
1
1
  import csv
2
2
  import os
3
3
 
4
- import cv2
4
+ from ..utils.misc import save_image
5
5
 
6
6
 
7
7
  def table_to_csv(table, ignore_line_break):
@@ -54,7 +54,7 @@ def save_figure(
54
54
  filename = os.path.splitext(os.path.basename(out_path))[0]
55
55
  figure_name = f"{filename}_figure_{i}.png"
56
56
  figure_path = os.path.join(save_dir, figure_name)
57
- cv2.imwrite(figure_path, figure_img)
57
+ save_image(figure_img, figure_path)
58
58
 
59
59
 
60
60
  def convert_csv(
@@ -1,10 +1,10 @@
1
1
  import os
2
2
  import re
3
3
  from html import escape
4
-
5
- import cv2
6
4
  from lxml import etree, html
7
5
 
6
+ from ..utils.misc import save_image
7
+
8
8
 
9
9
  def convert_text_to_html(text):
10
10
  """
@@ -122,7 +122,7 @@ def figure_to_html(
122
122
  filename = os.path.splitext(os.path.basename(out_path))[0]
123
123
  figure_name = f"{filename}_figure_{i}.png"
124
124
  figure_path = os.path.join(save_dir, figure_name)
125
- cv2.imwrite(figure_path, figure_img)
125
+ save_image(figure_img, figure_path)
126
126
 
127
127
  elements.append(
128
128
  {
@@ -180,8 +180,13 @@ def convert_html(
180
180
  elements = sorted(elements, key=lambda x: x["order"])
181
181
 
182
182
  html_string = "".join([element["html"] for element in elements])
183
- parsed_html = html.fromstring(html_string)
184
- formatted_html = etree.tostring(parsed_html, pretty_print=True, encoding="unicode")
183
+ if not len(html_string) == 0:
184
+ parsed_html = html.fromstring(html_string)
185
+ formatted_html = etree.tostring(
186
+ parsed_html, pretty_print=True, encoding="unicode"
187
+ )
188
+ else:
189
+ formatted_html = ""
185
190
 
186
191
  return formatted_html, elements
187
192
 
@@ -1,7 +1,7 @@
1
1
  import json
2
2
  import os
3
3
 
4
- import cv2
4
+ from ..utils.misc import save_image
5
5
 
6
6
 
7
7
  def paragraph_to_json(paragraph, ignore_line_break):
@@ -33,7 +33,7 @@ def save_figure(
33
33
  filename = os.path.splitext(os.path.basename(out_path))[0]
34
34
  figure_name = f"{filename}_figure_{i}.png"
35
35
  figure_path = os.path.join(save_dir, figure_name)
36
- cv2.imwrite(figure_path, figure_img)
36
+ save_image(figure_img, figure_path)
37
37
 
38
38
 
39
39
  def convert_json(inputs, out_path, ignore_line_break, img, export_figure, figure_dir):
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import re
3
3
 
4
- import cv2
4
+ from ..utils.misc import save_image
5
5
 
6
6
 
7
7
  def escape_markdown_special_chars(text):
@@ -89,7 +89,7 @@ def figure_to_md(
89
89
  filename = os.path.splitext(os.path.basename(out_path))[0]
90
90
  figure_name = f"{filename}_figure_{i}.png"
91
91
  figure_path = os.path.join(save_dir, figure_name)
92
- cv2.imwrite(figure_path, figure_img)
92
+ save_image(figure_img, figure_path)
93
93
 
94
94
  elements.append(
95
95
  {
@@ -1,3 +1,6 @@
1
+ import cv2
2
+
3
+
1
4
  def load_charset(charset_path):
2
5
  with open(charset_path, "r", encoding="utf-8") as f:
3
6
  charset = f.read()
@@ -9,6 +12,15 @@ def filter_by_flag(elements, flags):
9
12
  return [element for element, flag in zip(elements, flags) if flag]
10
13
 
11
14
 
15
+ def save_image(img, path):
16
+ success, buffer = cv2.imencode(".jpg", img)
17
+ if not success:
18
+ raise ValueError("Failed to encode image")
19
+
20
+ with open(path, "wb") as f:
21
+ f.write(buffer.tobytes())
22
+
23
+
12
24
  def calc_overlap_ratio(rect_a, rect_b):
13
25
  intersection = calc_intersection(rect_a, rect_b)
14
26
  if intersection is None: