From fc58fd59acb172e928ee074b83c1b75341ddcb25 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 13 Jun 2026 15:53:18 +0000 Subject: [PATCH] Flatten layout: move py_docx files into src; update imports and Dockerfile --- Dockerfile | 8 ++++---- pyproject.toml | 4 ++-- src/{py_docx => }/__init__.py | 0 src/{py_docx => }/docx_tools.py | 2 +- src/{py_docx => }/security.py | 0 src/{py_docx => }/server.py | 6 +++--- src/{py_docx => }/templates.py | 0 7 files changed, 10 insertions(+), 10 deletions(-) rename src/{py_docx => }/__init__.py (100%) rename src/{py_docx => }/docx_tools.py (99%) rename src/{py_docx => }/security.py (100%) rename src/{py_docx => }/server.py (99%) rename src/{py_docx => }/templates.py (100%) diff --git a/Dockerfile b/Dockerfile index 5f1ded2..162ae01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,12 +41,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # Copy project metadata and source before installing COPY pyproject.toml ./ -COPY src/py_docx ./src/py_docx +COPY src ./src # Install Python dependencies (including this package) RUN pip install --upgrade pip && pip install . -# Ensure py_docx is importable at runtime +# Ensure modules in src are importable at runtime ENV PYTHONPATH="/app/src" # Create runtime dirs @@ -67,7 +67,7 @@ EXPOSE 3000 # Health check (ensure module is importable) HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ - CMD python -c "import py_docx.server; print('ok')" || exit 1 + CMD python -c "from server import main; print('ok')" || exit 1 # Default: Streamable HTTP for OpenWebUI MCP -ENTRYPOINT ["python", "-m", "py_docx.server"] +ENTRYPOINT ["python", "-m", "server"] diff --git a/pyproject.toml b/pyproject.toml index 2d70544..c611743 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,8 +19,8 @@ dependencies = [ ] [project.scripts] -py-docx-mcp = "py_docx.server:main" +py-docx-mcp = "server:main" [tool.setuptools.packages.find] where = ["src"] -include = ["py_docx*"] +include = ["*"] diff --git a/src/py_docx/__init__.py b/src/__init__.py similarity index 100% rename from src/py_docx/__init__.py rename to src/__init__.py diff --git a/src/py_docx/docx_tools.py b/src/docx_tools.py similarity index 99% rename from src/py_docx/docx_tools.py rename to src/docx_tools.py index 94cdcba..a1def2f 100644 --- a/src/py_docx/docx_tools.py +++ b/src/docx_tools.py @@ -16,7 +16,7 @@ from docx.enum.text import WD_ALIGN_PARAGRAPH from PIL import Image as PILImage from io import BytesIO -from py_docx.security import SecurityConfig +from security import SecurityConfig def file_to_result(path: str, return_content: bool = False) -> Any: diff --git a/src/py_docx/security.py b/src/security.py similarity index 100% rename from src/py_docx/security.py rename to src/security.py diff --git a/src/py_docx/server.py b/src/server.py similarity index 99% rename from src/py_docx/server.py rename to src/server.py index 9cf57ba..0c36aba 100644 --- a/src/py_docx/server.py +++ b/src/server.py @@ -9,9 +9,9 @@ from typing import Any from mcp.server.fastmcp import FastMCP import uvicorn -from py_docx.docx_tools import DocxToolsProvider -from py_docx.security import SecurityConfig, is_command_allowed -from py_docx.templates import list_templates +from docx_tools import DocxToolsProvider +from security import SecurityConfig, is_command_allowed +from templates import list_templates logging.basicConfig( level=logging.INFO, diff --git a/src/py_docx/templates.py b/src/templates.py similarity index 100% rename from src/py_docx/templates.py rename to src/templates.py