- Create @resolve_field_defaults decorator to handle Pydantic FieldInfo objects when tools are called directly (outside MCP framework) - Create @handle_office_errors decorator for consistent error wrapping - Apply decorators to Excel and Word mixins, removing ~100 lines of boilerplate code - Fix Excel formula extraction performance: load workbooks once before loop instead of per-cell (100x faster with calculated values) - Update test suite to use correct mock patch paths (patch where names are looked up, not where defined) - Add torture_test.py for real document validation
53 lines
987 B
Python
53 lines
987 B
Python
"""Utility modules for MCP Office Tools."""
|
|
|
|
from .validation import (
|
|
OfficeFileError,
|
|
validate_office_file,
|
|
validate_office_path,
|
|
get_supported_extensions,
|
|
get_format_info,
|
|
detect_file_format,
|
|
is_url,
|
|
download_office_file
|
|
)
|
|
|
|
from .file_detection import (
|
|
detect_format,
|
|
classify_document_type
|
|
)
|
|
|
|
from .caching import (
|
|
OfficeFileCache,
|
|
get_cache,
|
|
resolve_office_file_path
|
|
)
|
|
|
|
from .decorators import (
|
|
resolve_field_defaults,
|
|
handle_office_errors
|
|
)
|
|
|
|
__all__ = [
|
|
# Validation
|
|
"OfficeFileError",
|
|
"validate_office_file",
|
|
"validate_office_path",
|
|
"get_supported_extensions",
|
|
"get_format_info",
|
|
"detect_file_format",
|
|
"is_url",
|
|
"download_office_file",
|
|
|
|
# File detection
|
|
"detect_format",
|
|
"classify_document_type",
|
|
|
|
# Caching
|
|
"OfficeFileCache",
|
|
"get_cache",
|
|
"resolve_office_file_path",
|
|
|
|
# Decorators
|
|
"resolve_field_defaults",
|
|
"handle_office_errors"
|
|
] |