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:
parent
9d6a9fc24c
commit
22f657b32b
@ -3,7 +3,7 @@
|
|||||||
FastMCP server providing organized tools for processing Word, Excel, PowerPoint documents
|
FastMCP server providing organized tools for processing Word, Excel, PowerPoint documents
|
||||||
including both modern formats (.docx, .xlsx, .pptx) and legacy formats (.doc, .xls, .ppt).
|
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.)
|
- UniversalMixin: Format-agnostic tools (extract_text, extract_images, etc.)
|
||||||
- WordMixin: Word-specific tools (convert_to_markdown, etc.)
|
- WordMixin: Word-specific tools (convert_to_markdown, etc.)
|
||||||
- ExcelMixin: Excel-specific tools (future expansion)
|
- 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())
|
TEMP_DIR = os.environ.get("OFFICE_TEMP_DIR", tempfile.gettempdir())
|
||||||
DEBUG = os.environ.get("DEBUG", "false").lower() == "true"
|
DEBUG = os.environ.get("DEBUG", "false").lower() == "true"
|
||||||
|
|
||||||
# Initialize mixins - each mixin registers its tools with the app
|
# Initialize mixin components
|
||||||
universal_mixin = UniversalMixin(app)
|
universal_component = UniversalMixin()
|
||||||
word_mixin = WordMixin(app)
|
word_component = WordMixin()
|
||||||
excel_mixin = ExcelMixin(app)
|
excel_component = ExcelMixin()
|
||||||
powerpoint_mixin = PowerPointMixin(app)
|
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
|
# Note: All helper functions are still available from server_legacy.py for import by mixins
|
||||||
# This allows gradual migration while maintaining backward compatibility
|
# This allows gradual migration while maintaining backward compatibility
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
|
"""Entry point for the MCP Office Tools server."""
|
||||||
import asyncio
|
import asyncio
|
||||||
from fastmcp.server import stdio_server
|
from fastmcp.server import stdio_server
|
||||||
|
|
||||||
async def main():
|
async def run_server():
|
||||||
await stdio_server(app)
|
await stdio_server(app)
|
||||||
|
|
||||||
asyncio.run(main())
|
asyncio.run(run_server())
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user