From 22f657b32bd461e49a90240e68f9c605f2aeffc2 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Fri, 26 Sep 2025 14:15:25 -0600 Subject: [PATCH] Fix server entry point for pyproject.toml script - Add main() function back to server.py for CLI script entry point - Maintains FastMCP MCPMixin pattern while fixing uvx execution - Server now starts properly with 'uvx --from . mcp-office-tools' - Preserves all 7 tools with official mixin registration --- src/mcp_office_tools/server.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/mcp_office_tools/server.py b/src/mcp_office_tools/server.py index 12bb330..8626697 100644 --- a/src/mcp_office_tools/server.py +++ b/src/mcp_office_tools/server.py @@ -3,7 +3,7 @@ FastMCP server providing organized tools for processing Word, Excel, PowerPoint documents including both modern formats (.docx, .xlsx, .pptx) and legacy formats (.doc, .xls, .ppt). -Architecture uses mixin pattern for clean separation of concerns: +Architecture uses official FastMCP MCPMixin pattern for clean separation of concerns: - UniversalMixin: Format-agnostic tools (extract_text, extract_images, etc.) - WordMixin: Word-specific tools (convert_to_markdown, etc.) - ExcelMixin: Excel-specific tools (future expansion) @@ -24,20 +24,30 @@ app = FastMCP("MCP Office Tools") TEMP_DIR = os.environ.get("OFFICE_TEMP_DIR", tempfile.gettempdir()) DEBUG = os.environ.get("DEBUG", "false").lower() == "true" -# Initialize mixins - each mixin registers its tools with the app -universal_mixin = UniversalMixin(app) -word_mixin = WordMixin(app) -excel_mixin = ExcelMixin(app) -powerpoint_mixin = PowerPointMixin(app) +# Initialize mixin components +universal_component = UniversalMixin() +word_component = WordMixin() +excel_component = ExcelMixin() +powerpoint_component = PowerPointMixin() + +# Register all decorated methods with prefixes to avoid name collisions +universal_component.register_all(app, prefix="") # No prefix for universal tools +word_component.register_all(app, prefix="") # No prefix for word tools +excel_component.register_all(app, prefix="excel") # Prefix for future excel tools +powerpoint_component.register_all(app, prefix="ppt") # Prefix for future powerpoint tools # Note: All helper functions are still available from server_legacy.py for import by mixins # This allows gradual migration while maintaining backward compatibility -if __name__ == "__main__": +def main(): + """Entry point for the MCP Office Tools server.""" import asyncio from fastmcp.server import stdio_server - async def main(): + async def run_server(): await stdio_server(app) - asyncio.run(main()) \ No newline at end of file + asyncio.run(run_server()) + +if __name__ == "__main__": + main() \ No newline at end of file