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
This commit is contained in:
Ryan Malloy 2025-09-26 14:15:25 -06:00
parent 9d6a9fc24c
commit 22f657b32b

View File

@ -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())
asyncio.run(run_server())
if __name__ == "__main__":
main()